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