【CodeForces】[546A]Soldier and Bananas

文章字数:120

问题描述

问题分析

直接运算
并没有什么弯

注意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

该内容采用 CC BY-NC-SA 4.0 许可协议。

如果对您有帮助或存在意见建议,欢迎在下方评论交流。

加载中...