A. Tennis Tournament
time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

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
Note

In the first example will be three rounds:

  1. in the first round will be two matches and for each match 5 bottles of water are needed (two for each of the participants and one for the judge),
  2. in the second round will be only one match, so we need another 5 bottles of water,
  3. in the third round will also be only one match, so we need another 5 bottles of water.

So in total we need 20 bottles of water.

In the second example no participant will move on to some round directly.

题意:
有n个人两两对决,每场对决有一个裁判。
每个选手每次参加比赛需要b瓶水,并且裁判需要一瓶。并且选手各需要毛巾p条。
(题意没有明说,需要瞎猜)每个人的毛巾可以循环使用,每个人从比赛到结束都只需要p条毛巾。
问总共需要的水和毛巾数量。

  

题解:
直接模拟每轮比赛即可。

  

 #include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std; int n, b, p; int main() {
scanf("%d%d%d", &n, &b, &p);
int bottles = , towels = n * p;
while(n > ) {
int k = ;
while(k * <= n) k <<= ;
int m = n - k + k / ;
int matches = k / ;
bottles += matches * ( * b + );
n = m;
}
printf("%d %d\n", bottles, towels);
return ;
}

Codeforces CF#628 Education 8 A. Tennis Tournament的更多相关文章

  1. Codeforces CF#628 Education 8 F. Bear and Fair Set

    F. Bear and Fair Set time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  2. Codeforces CF#628 Education 8 E. Zbazi in Zeydabad

    E. Zbazi in Zeydabad time limit per test 5 seconds memory limit per test 512 megabytes input standar ...

  3. Codeforces CF#628 Education 8 D. Magic Numbers

    D. Magic Numbers time limit per test 2 seconds memory limit per test 256 megabytes input standard in ...

  4. Codeforces CF#628 Education 8 C. Bear and String Distance

    C. Bear and String Distance time limit per test 1 second memory limit per test 256 megabytes input s ...

  5. Codeforces CF#628 Education 8 B. New Skateboard

    B. New Skateboard time limit per test 1 second memory limit per test 256 megabytes input standard in ...

  6. Educational Codeforces Round 8 A. Tennis Tournament 暴力

    A. Tennis Tournament 题目连接: http://www.codeforces.com/contest/628/problem/A Description A tennis tour ...

  7. CF 628A --- Tennis Tournament --- 水题

    CF 628A 题目大意:给定n,b,p,其中n为进行比赛的人数,b为每场进行比赛的每一位运动员需要的水的数量, p为整个赛程提供给每位运动员的毛巾数量, 每次在剩余的n人数中,挑选2^k=m(m & ...

  8. CodeForces - 283E Cow Tennis Tournament

    Discription Farmer John is hosting a tennis tournament with his n cows. Each cow has a skill level s ...

  9. Codeforces Round #382 (Div. 2)C. Tennis Championship 动态规划

    C. Tennis Championship 题目链接 http://codeforces.com/contest/735/problem/C 题面 Famous Brazil city Rio de ...

随机推荐

  1. java project中 xml文件路径问题

    xml文件默认是和src文件平级的,当不在project根目录下时,java代码中使用xml文件时需要写为这种形式:“/src/..../bean.xml”

  2. linux几个常用的命令及获取帮助的方法

    date:时间管理,可以显示.修改系统时间.  设定时间:格式:MMDDhhmm[[cc]yy][.ss]其中MM为月分,DD为日期,hh为小时,mm为分钟,CC为年的前两位 YY为年分的后两位,.s ...

  3. 复习(2)【postman,charles,filezilla server】

    Postman是一款功能强大的网页调试与发送网页HTTP请求的Chrome插件.通常我们可以用它来测试接口. Charles是在Mac下常用的网络封包截取工具,在做移动开发时,我们为了调试与服务器端的 ...

  4. Ubuntu14.04 64位配置Caffe 教程(基于CUDA7.5)

    最新博客地址已转到: http://blog.csdn.net/zzlyw?viewmode=contents   ------------------------------------------ ...

  5. mysql load data 乱码

    解决方案: http://stackoverflow.com/questions/26256421/sql-load-data-infile-utf8-issue 即: load data local ...

  6. 点击空白处 div隐藏掉了

    $(document).on('click',function (e) { var target = $(e.target); if(target.closest(".login-box&q ...

  7. maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令

    maven发布项目到私服-snapshot快照库和release发布库的区别和作用及maven常用命令 在日常的工作中由于各种原因,会出现这样一种情况,某些项目并没有打包至mvnrepository. ...

  8. 从C++实现Ping开始说起

    在C++中实现ping功能,并不难.但真正了解ping是需要花费一番功夫的. Ping功能是在ICMP基础上实现的.IP协议并不是一个可靠的协议,它不保证数据被送达,那么,保证数据送达的工作应该由其他 ...

  9. SQL批量增加修改数据

    insert into A表(字段1,字段2) select 字段1,字段2 From B表 [注:字段类型.字段数应相同] --批量进行修改ID值 declare @i int begin )) F ...

  10. 【日记】搭建一个node本地服务器

    用node搭建一个本地http服务器.首先了解htpp服务器原理 HTTP协议定义Web客户端如何从Web服务器请求Web页面,以及服务器如何把Web页面传送给客户端.HTTP协议采用了请求/响应模型 ...