CodeForces - 628A - A. Tennis Tournament


题目连接: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

5 2 3

Sample Output

20 15

Sample Input

8 2 4

Sample Output

35 32

解题思路

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

AC代码

#include<iostream>
using namespace std;
int main () {
    int n, b, p;
    int sumb = 0;
    int sump = 0;
    cin >> n >> b >> p;
    sump = n * p;
    while(n != 1) {  
        sumb += n/2;  
        n = n/2 + n%2;  
    } 
    sumb = 2 * b * sumb + sumb;
    printf("%d %d", sumb, sump);
    return 0; 
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值