C++60分求助

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

你的i是比月份小1的, cout<<-(i+1)就行了
by jiajiaaixue @ 2023-01-14 10:17:05


``` #include<iostream> using namespace std; int main() { int x=0,n,m=0,c=0; for(int x=1;x<=12;x++) { cin>>n; m=m+300-n; c=c+m/100; m=m%100; if(m<0) { cout<<-x; return 0; } } cout<<m+100*c*1.2; return 0; } ```
by wuzehui123456 @ 2023-02-02 16:20:15


```cpp #include<bits/stdc++.h> using namespace std; int mo[13]; int money,mum,l,v,ll; int main() { for(int i=1;i<=12;i++) { cin>>mo[i]; if(ll==0) { money+=300; if(mo[i]>money) { v=i;ll=1; } else money-=mo[i]; if(money/100!=0) { l=money/100; mum+=l*100; money-=l*100; } if(i==12&&v==0) {cout<<mum*1.2+money;return 0;} } } cout<<"-"<<v; return 0; } ```
by ceqowows @ 2023-02-19 11:52:43


@[jiajiaaixue](/user/717627) 通过了,谢谢!
by wangyb2011 @ 2023-04-03 19:19:24


|