CodeForces - 628A A. Tennis Tournament

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;  
}  


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

kunsir_

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值