大佬求助

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

是不是因为if特判 ``` if (c<0) cout<<0-i; ``` 应该加到循环中? 下面是我的AC代码 ```cpp #include<bits/stdc++.h> using namespace std; typedef long long ll; int main() { int sum=0,ans=0,a; for(int i=1;i<=12;i++) { ans+=300; cin>>a; ans-=a; if(ans<0) { cout<<-i; return 0; } sum+=ans/100; ans%=100; } cout<<sum*120+ans; return 0; } ```
by gaoleng_luogu_name @ 2023-06-30 20:04:37


谢谢
by Howells @ 2023-06-30 20:22:34


|