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. 修改html页面文字选中样式

    ::selection { background-color: #31B0D5; color: #fff; text-shadow: 0 1px 0 rgba(0,0,0,.2); }

  2. Owin Self Host

    http://owin.org/ Owin 定义了webserver和webapplication之间的标准接口,目标就是为了解耦webapplication对webserver的依赖, 就是说以后可 ...

  3. Camtasia 录屏说明

    准备好要录制的屏幕或网页,在即将播放的位置暂停住. 从开始菜单位置“TechSmith”启动Camtasia Recorder 8,其界面如下所示: 注意,要录制系统声音,须在Recorded inp ...

  4. Ansible 模块命令介绍

    copy模块: 目的:把主控端/root目录下的a.sh文件拷贝到到指定节点上 命令:ansible 10.1.1.113 -m copy -a 'src=/root/a.sh dest=/tmp/' ...

  5. sh7.创建yum源脚本练习

    练习1, 写一个脚本分别计算1-100,之间奇数和偶数之和 ji_sum.sh #!/bin/bash # let ..};do ] -eq ];then let sum+=I fi done ech ...

  6. 等差数列(bzoj 3357)

    Description     约翰发现奶牛经常排成等差数列的号码.他看到五头牛排成这样的序号:"1,4,3,5,7" 很容易看出"1,3,5,7"是等差数列. ...

  7. java方法强制传递引用参数(做为返回值),改变被传递参数值。

    Java传递参数分为2种: 值类型,Java里面也叫简单类型,这种参数类型的传递的是它的副本拷贝: 引用类型,传递的是对象引用地址,如果在方法内改变该参数对象属性即是对原引用对象的改变:如果不想这样传 ...

  8. ModPagespeed for Apache安装配置

    1.安装ModPagespeed #32位wget https://dl-ssl.google.com/dl/linux/direct/mod-pagespeed-stable_current_i38 ...

  9. 复制远程共享文件夹内容到本地(python脚本实例)

    本人自用脚本(python): #-*- coding:utf-8 -*- import sys , os , re def copyFileDir(srcFilename , desFilename ...

  10. 【Java EE 学习 74 下】【数据采集系统第六天】【使用Jfreechart的统计图实现】【将JFreechart整合到项目中】

    之前说了JFreechart的基本使用方法,包括生成饼图.柱状统计图和折线统计图的方法.现在需要将其整合到数据采集系统中根据调查结果生成三种不同的统计图. 一.统计模型的分析和设计 实现统计图显示的流 ...