Serendi_Pity @ 2022-10-21 21:50:22
#include<iostream>
using namespace std;
int main()
{
int k,i,s1=0;
cin>>k;
for(i=1;i<=k;i++){
s1+=i*i;
}
cout<<s1;
return 0;
}
by pengzihao @ 2022-10-21 21:54:47
这要多重循环
by I_AK_CTSC @ 2022-10-21 21:55:05
题目中说了,说连续n天都是n枚金币,但是你的程序很明显是第N天n枚金币,有很大区别
by I_AK_CTSC @ 2022-10-21 21:56:26
@sjz520
by I_AK_CTSC @ 2022-10-21 21:58:05
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,coin=0;
cin>>n;
scanf("%d",&n);
for(i=1;n-i>=0;)
{
coin+=i*i;/*金币coin*/
n-=i;
++i;
}
printf("%d\n",coin+n*i);
return 0;
}
//这是我的AC程序,看看我的循环你就明白你错在哪里了
by I_AK_CTSC @ 2022-10-21 21:59:25
//草,程序进行了2次输入洛谷没看出来……
by Serendi_Pity @ 2022-10-21 21:59:32
@pengzihao @I_AK_CTSC
谢谢,我搞懂了
已AC