水题 Codeforces Round #304 (Div. 2) A. Soldier and Bananas

 

题目传送门

 1 /*  2  水题:ans = (1+2+3+...+n) * k - n,开long long  3 */  4 #include <cstdio>  5 #include <algorithm>  6 #include <cstring>  7 #include <cmath>  8 using namespace std;  9 10 typedef long long ll; 11 12 int main(void) //Codeforces Round #304 (Div. 2) A. Soldier and Bananas 13 { 14 int k, n, w; 15 while (scanf ("%d%d%d", &k, &n, &w) == 3) 16  { 17 ll sum = (1 + w) * w / 2 * k; 18 if (sum < n) puts ("0"); 19 else printf ("%I64d\n", sum - n); 20  } 21 22 return 0; 23 } 24 25 26 /* 27 3 17 4 28 */

 

你可能感兴趣的:(codeforces)