Problem--546A--Codeforces--Soldier and Bananas
来源:互联网 发布:手机壁纸diy软件 编辑:程序博客网 时间:2024/06/01 15:01
A.Soldier and Bananas
time limit per test:1 second
memory limit per test:256 megabytes
inputstandard inputA soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second one and so on (in other words, he has to pay i·k dollars for the i-th banana).
He has n dollars. How many dollars does he have to borrow from his friend soldier to buy w bananas?
Input
The first line contains three positive integers k, n, w (1 ≤ k, w ≤ 1000, 0 ≤ n ≤ 109), the cost of the first banana, initial number of dollars the soldier has and number of bananas he wants.Output
Output one integer — the amount of dollars that the soldier must borrow from his friend. If he doesn’t have to borrow money, output 0.Examples:
input
3 17 4
output
13
#include<stdio.h>int main(){ int k,n,w,sum=0,i=1; scanf("%d%d%d",&k,&n,&w); while(w--) { sum+=i*k; i++; } sum<n?printf("0\n"):printf("%d\n",sum-n);}
0 0
- Problem--546A--Codeforces--Soldier and Bananas
- CodeForces 546A Soldier and Bananas
- Soldier and Bananas( CodeForces - 546A)
- CodeForces-546A-Soldier and Bananas
- 【CodeForces】[546A]Soldier and Bananas
- 【codeforces 546A】Soldier and Bananas
- codeforces 546A Soldier and Bananas
- CodeForces 546 A - Soldier and Bananas(模拟求和)
- codeforces 546A(Soldier and Bananas) Java
- A. Soldier and Bananas
- CF 546A Soldier and Bananas
- CF 546A-Soldier and Bananas
- A. Soldier and Bananas(CF546) Codeforces Round #304 (Div. 2)
- Codeforces刷题之路——546A Soldier and Bananas
- Codeforces546A:Soldier and Bananas
- Coderforces Soldier and Bananas
- Soldier and Cards(Problem - 546C - Codeforces)
- #codeforces 546C# Soldier and Cards (模拟)
- interactivePopGestureRecognizer
- NodeJS入门(一)- 基本文件路由实现
- open-GOP
- 挑战练习题2.3动态规划 poj1742 Coins 多重背包
- JavaFX TableCell经验分享
- Problem--546A--Codeforces--Soldier and Bananas
- 关于IOException parsing XML document from ServletContext resource [/WEB-INF/applicationContext.xml]的解决
- Cookie 和 Session 的使用简记
- 371. Sum of Two Integers
- JavaScript for Kids 学习笔记1. 学习环境
- 【面试题】剑指offer21
- Linux下安装Hadoop集群(三台一主二从)
- Android消息机制(AsyncTask操控进度条(颜色)线程的用法)
- java web项目,post请求发送数据太大的处理方法