Online Judge【CodeForces】[546A]Soldier and Bananas问题描述 问题分析直接运算并没有什么弯注意int就足以储存数据不需要借钱时(n>res)输出 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 #include<stdio.h> int main() { int k,n,w; while(scanf("%d %d %d",&k,&n,&w)!=EOF) { int res=0; for(int i=1; i<=w; i++) res+=i*k; if(n>res) printf("0\n"); else printf("%d\n",res-n); } return 0; }题目地址:【CodeForces】[546A]Soldier and Bananas