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 ...
随机推荐
- 如何安装 第三方 Go 离线包? (GOPATH、 go install)
有时候 go get 比较慢,可以考虑用迅雷等下载工具下载下来,然后再本地安装, 如:code.google.com/p/go.net/websocket,如何安装这些离线包? 先在你的 GOPATH ...
- Python 登录系统
---------------------------------------------------------------------------------------- 该程序主要实现了以下3 ...
- php 全局变量
参考链接:http://www.cnblogs.com/borage/p/3645285.html
- 手机电脑Mac地址修改方法
1.什么是Mac地址? MAC(Media Access Control或者Medium Access Control)地址,意译为媒体访问控制,或称为物理地址.硬件地址,用来定义网络设备的位置.在O ...
- Func
Func<List<int>, string> getStr = (list) => { var returnStr = ""; if (list.A ...
- [BZOJ1552][Cerc2007]robotic sort
[BZOJ1552][Cerc2007]robotic sort 试题描述 输入 输入共两行,第一行为一个整数N,N表示物品的个数,1<=N<=100000.第二行为N个用空格隔开的正整数 ...
- canvas画圆(一)
仿第一次效果
- 项目 CTR预估
项目和数据介绍 给定查询和用户信息后预测广告点击率 搜索广告是近年来互联网的主流营收来源之一.在搜索广告背后,一个关键技术就是点击率预测-----pCTR(predict the click-thro ...
- 点击空白处 div隐藏掉了
$(document).on('click',function (e) { var target = $(e.target); if(target.closest(".login-box&q ...
- gradle
http://examples.javacodegeeks.com/core-java/gradle/gradle-hello-world-tutorial/