123sun123 @ 2018-02-28 14:30:04
using namespace std; int main() { for( int n;cin>>n; ) { int i=1,sum=0,m; int mon=0; for(i=1;i<n;i++) { sum=sum+i;
if((n-sum)<i)
{
m=i; break;
}
}
int j;
for(j=1;j<=m;j++)
{
mon=mon+j*j;
}
cout<<(mon+j*(n-sum));
} }
by 夢·壹生所愛 @ 2018-02-28 16:07:14
或许是循环没加=?
by 阔耐滴大纸张 @ 2018-02-28 16:19:02
#include<bits/stdc++.h>
using namespace std;
long long money,n,i,sy;
int main()
{
cin>>n;
while(n>=sy)
{
i++;
money+=i*i;
sy+=i;
}
cout<<money-(sy-n)*i;
return 0;
}
by 阔耐滴大纸张 @ 2018-02-28 16:19:06
@123sun123
by 123sun123 @ 2018-02-28 18:03:52
@lovelausanneforever 谢谢
by 123sun123 @ 2018-02-28 18:04:00
@阔耐滴大纸张 。。。