蒟蒻求助(悬赏谢谢)

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

```cpp #include<bits/stdc++.h> using namespace std; int ans,l; int main() { for(int i=1;i<=12;i++) { int a; cin>>a; ans+=300; if(ans<a){ cout<<"-"<<i; return 0; } ans-=a; if(ans/100>0) { l+=ans/100*100; ans=ans-ans/100*100; } } cout<<ans+l*1.2; return 0; } ``` 已AC
by C20252323tzy @ 2023-08-12 19:20:36


AC Code 仅供参考: ```c #include <bits/stdc++.h> using namespace std; int main() { int y, s = 0, m, x; for (int i = 1; i <= 12; i++) { cin >> y; s = 300 - y + s; if (s < 0) { cout << -i; break; } if (s >= 100) { x = s % 100; m += s - x; s = x; } } if (s >= 0) cout << s + m * 1.2; return 0; } ``` 本人不太擅长纠错误或者写注释啊。。。 将就着看吧。。。 求个关
by wzj0829 @ 2023-08-12 19:21:23


谢谢
by 魏蕴博 @ 2023-08-12 19:21:39


就是问关注有啥用吗 ``` #include<cstdio> using namespace std; int m=0,j=0,t,y;//j是津津手里的钱,m是存在妈妈里的钱 int main() { for(int i=1;i<=12;i++) { scjnf("%d",&y); t=j+300-y; j=t%100; m=m+t/100*100; if(t<0) { printf("-%d",i); return 0; } } printf("%.0lf",m*1.2+j); return 0; }
by Tanleyan @ 2023-08-19 17:18:43


|