#include<stdio.h> int main() { int n,i; int a=1,s=1,cnt=0; //cnt表示总金币数 scanf("%d",&n); for(i=0;i<n;i++){ //过于巧妙,我看到后叹为观止 cnt+=a; s--; if(s==0){ //天数达到金币数后,金币重置 a++; s=a; } } printf("%d",cnt); return 0; }
By signing up a 追梦算法网 universal account, you can submit code and join discussions in all online judging services provided by us.
Using your 追梦算法网 universal account