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).
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.
Print two integers x and y — the number of bottles and towels need for the tournament.
5 2 3
20 15
8 2 4
35 32
题意:有n个人打兵乓球比赛,两个人一组,赢的人直接晋级,输的淘汰,人数是奇数的时候剩下的一个人直接晋级。每组的每个运动员可以得到b瓶水,p个毛巾,裁判在每组比赛中得1瓶水,裁判没毛巾。问:共需多少瓶水,多少毛巾???
----------------------------------
人 数 | 2 | 3 | 4 | 5 | 6 |7
---------------------------------
比赛次数| 1 | 2 | 3 | 4 | 5 |6
----------------------------------
找出规律n个人打(n-1)场比赛,所以
水需要(n-1)+ (n-1)*2*b;
毛巾需要n*p;
AC代码:
#include<stdio.h>
#include<cstring>
#include<algorithm>
#define AC main()
using namespace std;
const int MYDD = 1103;
int AC {
int n, b, q;
scanf("%d %d %d", &n, &b, &q);
printf("%d %d\n", (n - 1) * (2*b + 1), n*q);
return 0;
}