Soldier and Bananas

Practice this coding question on Coding Gurukul.

Problem statement

A stall charges k coins for the first item, 2k for the second, and so on. A buyer wants n items and already has w coins. Find the additional money needed to pay for all items, or zero if the buyer has enough.

Input format

Three integers k w n.

Output format

Print the amount that must be borrowed.

Constraints

1 <= k,n <= 1000; 0 <= w <= 1000000000.

Sample input

4 10 3

Sample output

14

Sign in to run or submit a solution in C++, Java or Python.