呜呜呜,求救

P2669 [NOIP2015 普及组] 金币

shenyuze @ 2021-12-05 13:31:10

#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b=0,i=1,day=0;
    cin>>a;
    while(i<=a)
    {
        for(int x=1;x<=i;x++)
        {
        b=b+x;
        day++;
        }
        i++;
        if(day==a) break;
    }
    cout<<b;
}

怎么了???


by cnyh_673 @ 2021-12-05 13:36:20

第11行应该是b+=i;


by cnyh_673 @ 2021-12-05 13:39:04

而且if(day==a) break;这一句for循环里也要写一遍


|