time limit per test1 second

memory limit per test256 megabytes

inputstandard input

outputstandard output

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·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

【题目链接】:http://codeforces.com/contest/546/problem/A

【题解】



就是w个数的等差数列的求和公式。

然后如果钱够的话输出的是0!!!!

否则输出差的绝对值就好.

细心。



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; //const int MAXN = x;
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0); LL k,n,w; int main()
{
//freopen("F:\\rush.txt","r",stdin);
rel(k);rel(n);rel(w);
LL temp1 = (k + w*k)*w/2;
LL temp = n-temp1;
if (temp <0)
cout << abs(temp)<<endl;
else
puts("0");
return 0;
}

最新文章

  1. SVM分类与回归
  2. oracle安装操作及遇到的错误
  3. Javascript中构造函数与new命令2
  4. HDU 1565&amp;1569 方格取数系列(状压DP或者最大流)
  5. Android总结篇系列:Activity Intent Flags及Task相关属性
  6. HTTP详解(3)-http1.0 和http1.1 区别
  7. git撤销删除
  8. shape的属性(二)
  9. Cocos开发中Visual Studio下libcurl库开发环境设置
  10. MySQL主从设定
  11. C# 控制台窗口的显示与隐藏
  12. javascript中类的属性研究
  13. Java的容器类小结
  14. 线性结构与树形结构相互转换(ES6实现)
  15. 51nod 1179 最大的最大公约数
  16. 发运模块中如何创建Debug 文件
  17. JavaScript(八)
  18. A The Empire Age
  19. 使用Hbuilder手机debug
  20. 非业务 Oracle SQL 语句备份

热门文章

  1. C++ 指针与引用 知识点 小结
  2. 解决XCODE配置LLVM环境出现的问题
  3. 谈谈Command对象与数据检索
  4. GO语言学习(十二)Go 语言函数
  5. 洛谷 P1808 单词分类_NOI导刊2011提高(01)
  6. 细说GCD
  7. 【Codeforces Round #434 (Div. 1) B】Polycarp's phone book
  8. mysql 配置,还得多看看~
  9. android 登录和设置IP/端口功能
  10. struts2笔记---struts2的执行过程