Skip to content

Commit c617d3d

Browse files
committed
Soldier and Bananas
1 parent b62662c commit c617d3d

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

546A.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#include<iostream>
2+
using namespace std;
3+
4+
int main(){
5+
int k, n, w;
6+
cin>>k;
7+
cin>>n;
8+
cin>>w;
9+
10+
int sum = 0;
11+
for(int i = 1; i <= w; i++){
12+
sum += i*k;
13+
}
14+
int b = (sum - n) > 0 ? (sum - n) : 0;
15+
cout<<b;
16+
return 0;
17+
18+
}

0 commit comments

Comments
 (0)