题解 | #[NOIP2015]金币#
[NOIP2015]金币
https://www.nowcoder.com/practice/8f71f5670e6a45118d24d13868a2da9e
#include <stdio.h> int main() { int a = 0; scanf("%d", &a); int i = 0; int sum=0; int sum1=0; for(i=1;i<=a;i++) { sum+=i;//天数 sum1+=i*i;//金钱 if(sum>=a) { int b=sum-a; sum1=sum1-b*i; break; } } printf("%d", sum1); return 0; }