Tuesday, May 31, 2016

CODEFORCES problem 546A Soldier and Bananas

Problem link (Click here)

#include <iostream>
#include <cstdio>

using namespace std;

int main()
{
    int k,n,w;
    int rate;
    int cost=0;
    int loan;
    cin>> k >> n >> w;
    for(int i=1; i<=w; i++){
        rate=i*k;
        cost=cost+rate;
    }
    loan=cost-n;
    if(loan<0)
        loan=0;
    cout<<loan<<endl;

    return 0;
}

1 comment:

  1. Thank you, good program i needed it keep up the good work ;)

    ReplyDelete