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. 在Web工程中引入Jquery插件报错解决方案

    在学习Jquery插件的时候,遇到一个问题就是新建web工程后在WebRoot下引入Jquery插件的时候报错,不知道为什么好纠结,但是项目能正常运行,后来找到解决方案,在这里给大家分享一下. 解决方 ...

  2. mybatis问题is not known to the MapperRegistry

    is not known to the MapperRegistry mapper.xml里面对应的dao应该是interface而非class

  3. 使用Impersonation仿冒用户运行WCF 服务方法

    默认情况下,当我们把wcf服务器部署在IIS上时, 我们访问wcf时使用的是IIS内建的内建角色,对于IIS8.0,它被命名为ApplicationPoolIdentity, 一般来说,系统为每个应用 ...

  4. libvirt 安装篇

    1. 环境:Centos 7     python 2.7 2. 安装 sudo yum install  gcc  python-devel  libvirt libvirt-devel sudo ...

  5. java后台对前端输入的特殊字符进行转义

    转自:http://www.cnblogs.com/yangzhilong/p/5667165.html java后台对前端输入的特殊字符进行转义 HTML: 常见的帮助类有2个:一个是spring的 ...

  6. 算法练习_图的连通性问题(JAVA)

    一.问题 1.问题描述: 有n个点(1...n),输入整数对(8,9),表示8,9点之间存在相互的连接关系. 动态连通性问题--编写一段程序过滤掉所以无意义的整数对,即为在不破坏图连通性的前提下,以最 ...

  7. 关于SimpleAdapter和ListView结合使用,实现列表视图的笔记

    使用ListView需要为其添加适配器: 适配器有两种:1.ArrayAdapter  --用于单独文字显示 2.SimpleAdapter --用于文字和图片显示 这里主要记录SimpleAdapt ...

  8. C# 程序异常管理方案

    C# 程序异常管理方案 1.程序出现未处理异常(程序中未捕获异常.添加异常处理) 2.程序添加全局异常捕获 tip:程序已处理异常不在捕获范围内. /// <summary> /// 应用 ...

  9. Linux安装mariadb二进制版本

    上一篇说了mariadb编译安装过程,但在生产环境中一般使用发布好的二进制版本,由于安装过程和之前一样,不再详细叙述,只是简单概括一下安装过程: 1. 下载 地址为:https://downloads ...

  10. JQuery实现无刷新下拉加载图片

          最近做的一个项目需要做页面无刷新下拉加载图片,调研了一番,大多都采用检测滚动条达到底部,然后利用ajax加载下一页数据对页面数据进行添加,根据这一逻辑,自己写了一个,具体代码如下: JQu ...