帮忙看看那哪错了,40分

P2669 [NOIP2015 普及组] 金币

lixiaolan @ 2022-12-12 22:06:27

#include<bits/stdc++.h>
using namespace std;
int a,b;
int main(){
    cin>>a;
    for(int i=1;i<=a;i++)
        a=a-i,b=b+i*i;
    cout<<b;
    return 0;
}

by codejiahui @ 2022-12-12 23:35:54

@lixiaolan
如果它发到最后(设为第x次)不需要x天,但还是要发的,你这就算少了。
最后建议加判断


by lixiaolan @ 2022-12-13 10:10:20

@codejiahui 谢谢,AC了


by bbbbbba @ 2022-12-24 18:15:44

我要尿尿!


by shuyuan2016 @ 2022-12-25 20:38:34

#include <iostream> 
using namespace std;
int n,q,c,s;
int main(){
    cin>>n;
    c=q=1;  
    for(int i=1;i<=n;i++){
        s+=c;
        q--;
        if(q==0)
        {
            c++;
            q=c;
        }
    }
    cout<<s;    
    return 0;   
}

|