一遍通过

P2669 [NOIP2015 普及组] 金币

某杂工 @ 2017-10-29 15:02:50

#include<iostream>
#include<cmath>
using namespace std;
int main(){
    int qianshu=0;
    int tianshu;
    int i,j=0,k=0;
    cin>>tianshu;
    j=1;
    k=1;
    for(i=1;i<=tianshu;i++){
        qianshu=qianshu+j;
        if(k==i)
        {
            j++;
            k+=j;
        }
    }
    cout<<qianshu;
}

by 览遍千秋 @ 2017-10-29 15:06:36

你像极了刚学OI就发错误A+B题解的人


by yin5u @ 2017-10-29 15:11:53

你像极了刚学OI就发错误A+B题解的人 (队型)


by _xcc_ @ 2017-10-29 15:13:20

你像极了刚学OI就发错误A+B题解的人 (队型+1s)


by Frank06 @ 2017-10-29 15:21:49

这不是A+B啊。。。


by 0Koto @ 2017-10-29 15:26:08

秀1A的都是大佬(便乘)


by Conte_di_Cavour @ 2017-10-29 15:47:50

这种题我肯定CE爆0


by hn_ytc @ 2018-01-09 20:22:41

# include <iostream>
using namespace std;
int main()
{
    int K,N,ans=0;
    cin>>K;               
    for(N=1;K-N>=0;K-=N++)       
        ans+=N*N;               
    cout<<ans+K*N;
    return 0;
}

by hn_ytc @ 2018-01-09 20:22:50

OK了


by hn_ytc @ 2018-01-09 20:23:12

楼上赞同


by yy233 @ 2018-04-29 14:55:03

#include<bits/stdc++.h>
using namespace std;
int ans,k,i;
int main()
{
    cin>>k;
    while(k>=0)
    {
        ++i;
        ans+=i*i;
        k-=i;
    }
    cout<<ans+k*i<<endl;
    return 0;
}

|