Problem description

A 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·kdollars 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
解题思路:等差数列求前w项和,如果够钱,则输出0,否则就输出需要借钱的数目,水过。
AC代码:
 #include<bits/stdc++.h>
using namespace std;
int main(){
int k,n,w,r;
cin>>k>>n>>w;
r=((+w)*w/)*k;
if(r<=n)cout<<''<<endl;
else cout<<(r-n)<<endl;
return ;
}

B - Soldier and Bananas的更多相关文章

  1. Soldier and Bananas

    Soldier and Bananas 题目链接:http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=173141 题意: 给 ...

  2. 水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas

    题目传送门 /* 水题:ans = (1+2+3+...+n) * k - n,开long long */ #include <cstdio> #include <algorithm ...

  3. A - Soldier and Bananas

    Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Description A sold ...

  4. 【codeforces 546A】Soldier and Bananas

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 546A. Soldier and Bananas

      等差数列: 以k为首相,k为公差,w个数量的和与n的大小关系 输出max(sum-0,0) Java程序   import java.util.Scanner; public class A546 ...

  6. codeforces水题100道 第五题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas (math)

    题目链接:http://www.codeforces.com/problemset/problem/546/A题意:一个人现在有n元,它买第i根香蕉需要i*k元,问他要买w根香蕉的话,需要问他的朋友借 ...

  7. Codeforces Round #304 (Div. 2) -----CF546

    A. Soldier and Bananas   A soldier wants to buy w bananas in the shop. He has to pay k dollars for t ...

  8. codeforcess水题100道

    之所以在codeforces上找这100道水题的原因是为了巩固我对最近学的编程语言的掌握程度. 找的方式在codeforces上的PROBLEMSET中过的题最多的那些题里面出现的最前面的10个题型, ...

  9. Codeforces Round #304 (Div.2)

    A. Soldier and Bananas 题意:有个士兵要买w个香蕉,香蕉起步价为k元/个,每多买一个则贵k元.问初始拥有n元的士兵需要借多少钱? 思路:简单题 #include<iostr ...

随机推荐

  1. win7 64位装sql2000

    1.运行不了安装程序 右击安装exe文件->属性->兼容性->以xp sp3兼容和管理员身份 2.安装过程中提示“被挂起”的故障 解决:打开注册表编辑器,在HKEY_LOCAL_MA ...

  2. SLAM: Orb_SLAM中的ORB特征

    原文链接:什么是ORB 关于Orb特征的获取:参考 最新版的OpenCV中新增加的ORB特征的使用 ORB是是ORiented Brief 的简称,对Brief的特定性质进行了改进. ORB的描述在下 ...

  3. 进行https通信时服务器端下发的是一个证书链

    进行https通信时服务器端下发的是一个证书链,否则无法验证证书的有效性.

  4. WebForm 登陆test

    <script> window.onload = function () { document.getElementById("form1").onsubmit = f ...

  5. java操作Excel的poi的字体设置

    package com.java.poi; import org.apache.poi.hssf.usermodel.HSSFWorkbook;import org.apache.poi.ss.use ...

  6. php第六讲

    继承和静态 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w ...

  7. __int128的实现

    #include<bitset> #include<algorithm> #include<iostream> #include<string> #in ...

  8. salt 批量添加route路由

    安装net-tools包 因为其余机器没有网络,使用rpm包安装,并添加缺省路由. [root@web1 base]# tree . ├── add-route.sls ├── files │   └ ...

  9. PHP循环输出二维数组的数据

    //下面是一个例子$g_id = isset($_GET['id'])?$_GET['id']:'1';//定义变量$g_id,使用三元运算符是为了避免出现waring $p_id = ($g_id& ...

  10. Oracle数据库的性能调整

    oracle是一个高性能数据库软件.用户可以通过参数的调整,达到性能的优化.性能优化主要分为两部分:一是数据库管理员通过对系统参数的调整达到优化的目的,二是开发人员通过对应用程序的优化达到调整的目的. ...