CodeForces

来源:互联网 发布:武汉网络施工队 编辑:程序博客网 时间:2024/06/07 03:02

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.

Examples
input
5 2 3
output
20 15
input
8 2 4
output
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;  }  


原创粉丝点击