蒟蒻40分,求助

P1089 [NOIP2004 提高组] 津津的储蓄计划

你应该先扣除每月的预计花销,然后再判断当月的钱是否不够用,余额是否大于100,之后存钱。 用python的话大概是这样,看懂应该没啥问题 ```python save,mum_save = 0,0 for i in range(12): # 手中得到 300 save += 300 pay = int(input()) # 扣除每月预计花销 save -= pay # 当月余额不足,程序结束 if (save<0): print("-{}".format(i+1)) exit() # 预计余额超过 100,存钱 if save >= 100: mum_save += save // 100 save %= 100 save += mum_save * 120 print(save) ```
by Winds_Land @ 2024-01-27 11:43:42


如果没有取整输出就只有40 ------------ ```c #include<stdio.h> int main() { double in_for=0; int out_inform[12]; int cun=0,now_m=0,moth,a; for( a=0;a<12;a++) { scanf("%d",&out_inform[a]); } for( moth=0;moth<12;moth++) { now_m+=300; now_m-=out_inform[moth]; if(now_m<0) { printf("-%d",moth+1); return 0; } if(now_m>=100) { in_for+=((now_m/100)*100); now_m%=100; } } in_for*=1.2; printf("%.0lf",in_for+now_m); } ```
by DingZHen520 @ 2024-02-07 09:12:25


@[CHkuakeU](/user/1239495) printf(,0) 我加上.0就过了
by DingZHen520 @ 2024-02-07 09:13:19


@[DingZHen520](/user/1209614) 栓Q
by CHkuakeU @ 2024-02-21 15:00:46


|