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