2008shitou @ 2019-10-07 12:51:55
如题目
by Salty_Fish787 @ 2019-10-07 12:52:38
暴力循环
by 木木! @ 2019-10-07 12:52:56
@2008shitou 题解区全是思路
by JS_TZ_ZHR @ 2019-10-07 12:54:02
@Salty_Fish787 其实这题有O(1)做法
by 2008shitou @ 2019-10-07 12:54:58
1+2+2+3+3+3+4+4+4+4+5+5+5+5+5+6+6+6+6+6+6+……
by 2008shitou @ 2019-10-07 12:56:43
暴力法样例二对不了
by wjmqwq @ 2019-10-07 13:00:56
@2008shitou 你也暴露年龄了
by wjmqwq @ 2019-10-07 13:02:08
@Salty_Fish787 +1
by 2008shitou @ 2019-10-07 13:03:50
# include <cstdio>
using namespace std;
int main()
{
int K,N,coin=0;
scanf("%d",&K); //输入总天数K
for(N=1;K-N>=0;K-=N++) //第1天骑士可获得1枚金币(谁知道这一行的意思?)
coin+=N*N; //在接下来的连续N天里,骑士每天可获得N枚金币
printf("%d\n",coin+K*N); //输出骑士总共可获得的金币数
return 0;
}