Codeforces 546A Soldier and Bananas

A. Soldier and Bananas



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";

Post a Comment

0 Comments