Codeforces CF#628 Education 8 A. Tennis Tournament
1 second
256 megabytes
standard input
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).
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.
Print two integers x and y — the number of bottles and towels need for the tournament.
5 2 3
20 15
8 2 4
35 32
In the first example will be three rounds:
- 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),
- in the second round will be only one match, so we need another 5 bottles of water,
- 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的更多相关文章
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
- Educational Codeforces Round 8 A. Tennis Tournament 暴力
A. Tennis Tournament 题目连接: http://www.codeforces.com/contest/628/problem/A Description A tennis tour ...
- CF 628A --- Tennis Tournament --- 水题
CF 628A 题目大意:给定n,b,p,其中n为进行比赛的人数,b为每场进行比赛的每一位运动员需要的水的数量, p为整个赛程提供给每位运动员的毛巾数量, 每次在剩余的n人数中,挑选2^k=m(m & ...
- CodeForces - 283E Cow Tennis Tournament
Discription Farmer John is hosting a tennis tournament with his n cows. Each cow has a skill level s ...
- Codeforces Round #382 (Div. 2)C. Tennis Championship 动态规划
C. Tennis Championship 题目链接 http://codeforces.com/contest/735/problem/C 题面 Famous Brazil city Rio de ...
随机推荐
- 测试基础:Bug管理那些事_20160910
1.bug由来 虫子爬进主机引起继电器短路,导致机器故障.真正的缺陷是:主机散热孔少装了块金属丝,这样才能防止虫子爬到主机. 2.什么是bug? bug是缺陷的一种表现形式,而一个缺陷是可以引发多种b ...
- rewrite
http://www.iis.net/downloads/microsoft/url-rewrite
- 客户有两台windows服务器要做sql server双机切换
基本架构 2 windows 2008 server:安装成域控制器,实现故障转移(虚拟ip访问,共享磁盘阵列卷链接主服务器),安装sqlserver2012 1磁盘阵列共享卷:数据库文件放于其中,两 ...
- (转)C#根据当前时间获取周,月,季度,年度等时间段的起止时间
DateTime dt = DateTime.Now; //当前时间 DateTime startWeek = dt.AddDays( - Convert.ToInt32(dt.DayOfWeek.T ...
- docker笔记
安装...不说了 docker info 查看信息 docker pull ...拉取镜像 docker run -it [镜像名] 运行 docker ps查看当前运行的容器 docker ps ...
- 面向对象Part2
`变量: 成员变量:又叫全局变量,定义在类中,方法外面. 1).类成员变量. 使用Static 2).实例成员变量. 没有使用Static. 局部变量:出了成员变量,其他的都是局部变量. 1). ...
- c#延迟加载
public class BlogUser { public int Id { get; private set; } public Lazy<List<Article>> A ...
- Qt 程序打包发布
Qt 官方开发环境使用的动态链接库方式,在发布生成的exe程序时,需要复制一大堆 dll,Qt 官方开发环境里自带了一个工具:windeployqt.exe.在Qt安装目录如:C:\Qt\Qt5.7. ...
- JavaScript 中的尾调用
尾调用(Tail Call) 尾调用是函数式编程里比较重要的一个概念,它的意思是在函数的执行过程中,如果最后一个动作是一个函数的调用,即这个调用的返回值被当前函数直接返回,则称为尾调用,如下所示: f ...
- JS WEB 交互问题
1 webView----->js #import "ViewController.h" @interface ViewController () @property (no ...