Ouyyx2002 @ 2018-07-23 17:36:03
#include<bits/stdc++.h>
using namespace std;
int day0,nowday=0,m=0,n,k=1,q;
int money(int n)
{
if (n-q>k)
{k++;q=n;}
return k;
}
int main()
{
cin>>day0;
while(nowday<day0)
{
nowday++;
m=m+money(nowday);
}
cout<<m;
}
by freezone @ 2018-07-23 19:25:30
if (n-q>k) 你的意思是:if ((n-q)>k) 语法错误
by Frozen_Fire @ 2018-11-09 18:11:59
参考下
#include<bits/stdc++.h>
using namespace std;
int main(){
int n,coin=0,cnt=0;
scanf("%d",&n);
while(n-cnt-1>=0){
cnt++;
coin=coin+cnt*cnt;
n=n-cnt;
}
if(n!=0){
cnt++;
coin=coin+cnt*n;
}
printf("%d",coin);
return 0;
}