solution in c++
#include<bits/stdc++.h>
#include<string.h>
#include<stdio.h>
#include<math.h>
using namespace std;
int main()
{
int i, n, t, k, w;
long long sum=0;
cin>> k>>n>>w;
for(i=1; i<=w; i++){
sum = sum+(i*k);
}
if(sum<= n){
cout <<0<<"\n";
}
else cout << sum - n << "\n";
0 Comments
If you have any doubts, Please let me know