A. Soldier and Bananas
题意:有个士兵要买w个香蕉,香蕉起步价为k元/个,每多买一个则贵k元。问初始拥有n元的士兵需要借多少钱?
思路:简单题
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 int main() 5 { 6 int k, n, w; 7 scanf("%d%d%d", &k, &n, &w); 8 int tot = k * (1 + w)*w / 2; 9 if (tot <= n) printf("0\n"); 10 else printf("%d\n", tot - n); 11 12 return 0; 13 }