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 ...
随机推荐
- 纵观jBPM:从jBPM3到jBPM5以及Activiti5
http://www.infoq.com/cn/articles/rh-jbpm5-activiti5/ 作者 荣浩 发布于 2010年12月28日 | 注意:GTLC全球技术领导力峰会,500+CT ...
- pdfbox加载pdf时遇到wrappedioexception报错处理方式
现在一个项目要对pdf做处理.由于其中一个pdf约为80M左右,用pdfbox读取pdf时遇到了wrappedioexception错误.监控得到说内存不足.于是请教项目经理.他告诉我在Open De ...
- The Safe Navigation Operator (&.) in Ruby
The most interesting addition to Ruby 2.3.0 is the Safe Navigation Operator(&.). A similar opera ...
- mybatis配置自带缓存和第三方缓存
http://blog.csdn.net/grhlove123/article/details/47808025
- maven实战(04)_在pom中使用properties
使用常量不仅让代码变得简洁,更重要的是可以避免重复,在需要更改的时候,只需要修改一处,降低了错误发生的概率. <project> <modelVersion>4.0.0< ...
- Activity系列讲解---返回结果的处理
设想一下:由当前Activity跳转到其它Activity,从其它Activity再返回到当前Activity时,如何获取其它Activity存放的数据?下面用一个例子讲解, 点击selsect按钮跳 ...
- android键盘输入读取
android键盘输入读取 监控android键盘输入方式有两种,一种在java层实现,重写onKeyDown和onKeyUp方法.另一种是在jni层实现,监控/dev/input/event0键盘 ...
- 编译osgEarth2.8遇到gdal_vrt.h找不到的问题
在编译plugins osgearth_gdal的ReaderWriterGDAL.cpp的时候可能会遇到这个问题 gdal_vrt.h这个头文件在gdal-1.11.0\frmts\vrt目录下,从 ...
- vue.js 请求数据
VUE.JS var vm = new Vue({ el:"#list", data:{ gridData: "", }, mounted: function( ...
- Linux创建定时任务
例如: 要求每天23:59分备份lampp日志: 备份的文件名以当时的时间命名 格式为:201612241852_acces.log 备份到:/tmp/logs/目录下 1.新建shell脚本:vim ...