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 }
View Code

相关文章:

  • 2021-08-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-05
  • 2021-08-12
  • 2021-04-24
猜你喜欢
  • 2021-05-27
  • 2021-12-17
  • 2022-12-23
  • 2021-08-01
  • 2021-10-22
  • 2021-11-16
  • 2021-12-07
相关资源
相似解决方案