Break the Chocolate

Time Limit: 20 Sec  Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/546/problem/A

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

Sample Input

3 17 4

Sample Output

13

HINT

题意

你要买n个物品,物品的价格是i*k,然后问你还需要多少钱才行

题解:

啊,暴力暴力

代码:

  1. //qscqesze
  2. #include <cstdio>
  3. #include <cmath>
  4. #include <cstring>
  5. #include <ctime>
  6. #include <iostream>
  7. #include <algorithm>
  8. #include <set>
  9. #include <vector>
  10. #include <sstream>
  11. #include <queue>
  12. #include <typeinfo>
  13. #include <fstream>
  14. #include <map>
  15. #include <stack>
  16. typedef long long ll;
  17. using namespace std;
  18. //freopen("D.in","r",stdin);
  19. //freopen("D.out","w",stdout);
  20. #define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
  21. #define maxn 200001
  22. #define mod 10007
  23. #define eps 1e-9
  24. int Num;
  25. char CH[];
  26. //const int inf=0x7fffffff; //нчоч╢С
  27. const int inf=0x3f3f3f3f;
  28. /*
  29.  
  30. inline void P(int x)
  31. {
  32. Num=0;if(!x){putchar('0');puts("");return;}
  33. while(x>0)CH[++Num]=x%10,x/=10;
  34. while(Num)putchar(CH[Num--]+48);
  35. puts("");
  36. }
  37. */
  38. inline ll read()
  39. {
  40. ll x=,f=;char ch=getchar();
  41. while(ch<''||ch>''){if(ch=='-')f=-;ch=getchar();}
  42. while(ch>=''&&ch<=''){x=x*+ch-'';ch=getchar();}
  43. return x*f;
  44. }
  45. inline void P(int x)
  46. {
  47. Num=;if(!x){putchar('');puts("");return;}
  48. while(x>)CH[++Num]=x%,x/=;
  49. while(Num)putchar(CH[Num--]+);
  50. puts("");
  51. }
  52. //**************************************************************************************
  53.  
  54. int main()
  55. {
  56. ll k,n,w;
  57. cin>>k>>n>>w;
  58. ll ans=;
  59. for(int i=;i<=w;i++)
  60. ans+=k*i;
  61. cout<<max(ans-n,0LL)<<endl;
  62. }

Codeforces Round #304 (Div. 2) Break the Chocolate 水题的更多相关文章

  1. Codeforces Round #367 (Div. 2) A. Beru-taxi (水题)

    Beru-taxi 题目链接: http://codeforces.com/contest/706/problem/A Description Vasiliy lives at point (a, b ...

  2. Codeforces Round #334 (Div. 2) A. Uncowed Forces 水题

    A. Uncowed Forces Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/604/pro ...

  3. Codeforces Round #353 (Div. 2) A. Infinite Sequence 水题

    A. Infinite Sequence 题目连接: http://www.codeforces.com/contest/675/problem/A Description Vasya likes e ...

  4. Codeforces Round #304 (Div. 2) A B C 水

    A. Soldier and Bananas time limit per test 1 second memory limit per test 256 megabytes input standa ...

  5. Codeforces Round #306 (Div. 2) A. Two Substrings 水题

    A. Two Substrings Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/550/pro ...

  6. Codeforces Round #327 (Div. 2) A. Wizards' Duel 水题

    A. Wizards' Duel Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/prob ...

  7. Codeforces Round #360 (Div. 2) C. NP-Hard Problem 水题

    C. NP-Hard Problem 题目连接: http://www.codeforces.com/contest/688/problem/C Description Recently, Pari ...

  8. Codeforces Round #146 (Div. 1) A. LCM Challenge 水题

    A. LCM Challenge 题目连接: http://www.codeforces.com/contest/235/problem/A Description Some days ago, I ...

  9. Codeforces Round #335 (Div. 2) B. Testing Robots 水题

    B. Testing Robots Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://www.codeforces.com/contest/606 ...

随机推荐

  1. ubuntu之安装pycharm编辑器

    pycharm是Java写的,运行需要Java环境. 安装java jdk sudo add-apt-repository ppa:webupd8team/java sudo apt-get upda ...

  2. spring boot注解学习记

    @Component Compent等效于xml文件中的Bean标注,Autowired自动初始化Bean是通过查找Component注解实现的,在增加Component后还是Autowired找不到 ...

  3. openjudge-NOI 2.6-1808 公共子序列

    题目链接:http://noi.openjudge.cn/ch0206/1808/ 题解: 裸题…… #include<cstdio> #include<cstring> #d ...

  4. day41 - 异步IO、协程

    目录 (见右侧目录栏导航) - 1. 前言- 2. IO的五种模型- 3. 协程    - 3.1 协程的概念- 4. Gevent 模块    - 4.1 gevent 基本使用    - 4.2 ...

  5. C# 获取计算机cpu,硬盘,内存相关的信息

    using System;using System.Management; namespace MmPS.Common.Helper{ /// <summary> /// 获取计算机相关的 ...

  6. IEEEXtreme 9.0 - Digit Fun!

    博客中的文章均为 meelo 原创,请务必以链接形式注明 本文地址 Xtreme 9.0 - Digit Fun! 题目来源:第9届IEEE极限编程大赛第1题 Recurrence relations ...

  7. Windows下 Tensorflow安装问题: Could not find a version that satisfies the requirement tensorflow

    Tensorflow 需要 Python 3.5/3.6  64bit 版本: 具体的安装方式可查看:https://www.tensorflow.org/install/install_window ...

  8. 【LOJ】#2544. 「JXOI2018」游戏

    题解 九条可怜还有那么善良的一面??? 显然有些数在这个区间里没有数是它的约数,它们其中的最后一个取的一定就是\(t(p)\)的值 这样我们只需要枚举\(t(p)\)的值,这个值就是"没有任 ...

  9. 06易普优APS行业方案:包装印刷行业高级计划排程

    易普优APS行业方案:包装印刷行业高级计划排程 一.包装印刷行业发展概况 网络购物催生包装印刷行业迅猛发展,目前已具有万亿市场规模,全国包装印刷企业总数达30万家,其中规模以上企业只有2万多家,已然成 ...

  10. Java中的覆盖和隐藏以及final关键字

    Java覆盖和隐藏 (1) 变量只能被隐藏(包括静态和非静态),不能被覆盖: (2) 可以用子类的静态变量隐藏父类的静态变量,也可以用子类的非静态变量隐藏父类的静态变量,也可以用非最终变量(final ...