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.
#include <stdio.h>
int main()
{
int i,k,n,w,d,s=0;
scanf("%d%d%d",&k,&n,&w);
for(i = 0;i <= w;i++)
s+=k*i;
d = s - n;
if(d >= 0)
printf("%d\n",d);
else
printf("0\n");
return 0;
}