题解 | #[NOIP2015]金币#
https://www.nowcoder.com/practice/8f71f5670e6a45118d24d13868a2da9e
#include<stdio.h> int main() { int n,k; int sum=0; scanf("%d",&n); for (k=1;;k++) { if (n>(k*k-k)/2&&n<=(k*k+k)/2) break; sum=sum+k*k; } sum=sum+(n-(k*k-k)/2)*k; printf("%d",sum); return 0; }
感觉自己代码写的不错,新手自我感觉良好