# Codeforces546a:soldier and Bananas

Source: Internet
Author: User

A Soldier wants to Buy  w  bananas in the shop. He has to Pay  K  dollars for the first banana, 2 k  dollars for the second one and so on (in other words, he have to Pay  i · k  dollars for The  i -th banana).

He has n dollars. How many dollars does he has to borrow from his friend soldier to buy w bananas?

Input

The first line contains three positive integers k,? N,? w (1?? ≤?? k,? w?? ≤?? 0?≤, huh? N. ≤?109), the cost of the first banana, initial number of dollars the soldier have and number of bananas He wants.

Output

Output one integer-the amount of dollars, the soldier must borrow from his friend. If He doesn ' t has to borrow money, output 0.

Sample Test (s) input
`3 17 4`
Output
`13`
`Test instructions`
`To buy a W banana, the first k yuan, the second 2k, the first I i*k, now has n yuan, also how many yuan`
` #include <iostream> #include <stdio.h> #include <string.h> #include <string> #include <stack> #include <queue> #include <map> #include <set> #include < vector> #include <math.h> #include <bitset> #include <list> #include <algorithm> #include <climits>using namespace std; #define Lson 2*i#define Rson 2*i+1#define LS l,mid,lson#define RS mid+1,r,rson#define Up (I,x,y) for (i=x;i<=y;i++) #define DOWN (i,x,y) for (i=x;i>=y;i--) #define MEM (a,x) memset (A,x,sizeof (a)) #define  W (a) while (a) #define GCD (A, B) __gcd (A, b) #define LL long long#define N 5000005#define INF 0x3f3f3f3f#define EXP 1e-8#define Lowbit (x) (x&-x) const int mod = 1E9+7;    LL N,k,w;int Main () {int i;    LL sum = 0;    scanf ("%i64d%i64d%i64d", &k,&n,&w);        for (i = 1;i<=w;i++) sum +=i*k;        if (n>=sum) printf ("0\n");    else printf ("%i64d\n", sum-n); return 0;} `

Codeforces546a:soldier and Bananas

Related Keywords:

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

## A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

• #### Sales Support

1 on 1 presale consultation

• #### After-Sales Support

24/7 Technical Support 6 Free Tickets per Quarter Faster Response

• Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.