题解 | #[NOIP2015]金币#
[NOIP2015]金币
https://www.nowcoder.com/practice/8f71f5670e6a45118d24d13868a2da9e
#include<stdio.h> int main() { int k,i,n; int sum = 0; int num=0; scanf("%d", &k); for (int i = 1; num<=k;i++) { num+=i;//记天数 sum+=i*i;//记金币数 n=i; } printf("%d\n", sum-n*n+(k-(num-n))*n);//数学计算 return 0; }