CodeForces - 628A - A. Tennis Tournament

小鱼儿 2022-06-12 13:51 316阅读 0赞

题目连接:http://codeforces.com/problemset/problem/628/A

题目描述

Description

A tennis tournament with n participants is running. The participants are playing by an olympic system, so the winners move on and the losers drop out.

The tournament takes place in the following way (below, m is the number of the participants of the current round):

  • let k be the maximal power of the number 2 such that k ≤ m,
  • k participants compete in the current round and a half of them passes
    to the next round, the other m - k participants pass to the next
    round directly,
  • when only one participant remains, the tournament finishes.

Each match requires b bottles of water for each participant and one bottle for the judge. Besides p towels are given to each participant for the whole tournament.

Find the number of bottles and towels needed for the tournament.

Note that it’s a tennis tournament so in each match two participants compete (one of them will win and the other will lose).

Input

The only line contains three integers n, b, p (1 ≤ n, b, p ≤ 500) — the number of participants and the parameters described in the problem statement.

Output

Print two integers x and y — the number of bottles and towels need for the tournament.

Sample Input

  1. 5 2 3

Sample Output

  1. 20 15

Sample Input

  1. 8 2 4

Sample Output

  1. 35 32

解题思路

毛巾数 = 人数 * p;
计算出一共需要比多少场;
2 * b * 场数 = 运动员需要的;
场数 = 裁判需要的;
相加即可;

AC代码

  1. #include<iostream>
  2. using namespace std;
  3. int main () {
  4. int n, b, p;
  5. int sumb = 0;
  6. int sump = 0;
  7. cin >> n >> b >> p;
  8. sump = n * p;
  9. while(n != 1) {
  10. sumb += n/2;
  11. n = n/2 + n%2;
  12. }
  13. sumb = 2 * b * sumb + sumb;
  14. printf("%d %d", sumb, sump);
  15. return 0;
  16. }

发表评论

表情:
评论列表 (有 0 条评论,316人围观)

还没有评论,来说两句吧...

相关阅读

    相关 CodeForces679A

    [CodeForces679A][] 也是交互题,这个要稍微难一些. 考虑的过程大概是: \\(1\\)肯定没有问的价值,如果问过\\(2\\),那么除了\\(4\

    相关 CodeForces1214A

    [CodeForces1214A][] 说起来你们可能不信,这题硬生生卡了我\\(1h\\),我想了背包,扩欧,二分....等等一坨办法.结果最后还是用了\\(bfs\\)

    相关 codeforce 141A

    /字符串问题 没AC的人可能是没看清楚题目吧, 先大概说下题目大意: 给你3个字符串,如果第一个串和第二个串组合在一起可以等于第三个串就输出“Y