A. Tennis Tournament

题目连接:

http://www.codeforces.com/contest/628/problem/A

Description

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.

Sample Input

5 2 3

Sample Output

20 15

Hint

题意

有两种水,n个人参加比赛

每次都会选择出小于等于n的最大2的倍数,然后让这些人比赛,每个参加比赛的人可以获得b瓶A水,裁判也得有一瓶A水

然后每个人都会获得p瓶B水

然后问你打完所有比赛后,需要多少瓶A水,多少瓶B水

题解:

A题就不要想太多,直接暴力吧……

虽然O(1)公式也有

代码

#include<bits/stdc++.h>
using namespace std; vector<int> two;
int main()
{
long long n,b,p;
cin>>n>>b>>p;
long long ans = 0,ans2 = n*p;
while(n>1)
{
int t = (n)/2*2;
ans+=t*b+t/2;
n-=t/2;
}
cout<<ans<<" "<<ans2<<endl;
}

Educational Codeforces Round 8 A. Tennis Tournament 暴力的更多相关文章

  1. Codeforces Educational Codeforces Round 8 A. Tennis Tournament

    大致题意: 网球比赛,n个參赛者,每场比赛每位选手b瓶水+裁判1瓶水,所有比赛每一个參赛者p条毛巾 每一轮比赛有2^k个人參加比赛(k为2^k<=n中k的最大值),下一轮晋级人数是本轮每场比赛的 ...

  2. Educational Codeforces Round 1 A. Tricky Sum 暴力

    A. Tricky Sum Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/598/problem ...

  3. Educational Codeforces Round 8 B. New Skateboard 暴力

    B. New Skateboard 题目连接: http://www.codeforces.com/contest/628/problem/A Description Max wants to buy ...

  4. Educational Codeforces Round 19 E. Array Queries(暴力)(DP)

    传送门 题意 给出n个数,q个询问,每个询问有两个数p,k,询问p+k+a[p]操作几次后超过n 分析 分块处理,在k<sqrt(n)时,用dp,大于sqrt(n)用暴力 trick 代码 #i ...

  5. Codeforces Educational Codeforces Round 17 Problem.A kth-divisor (暴力+stl)

    You are given two integers n and k. Find k-th smallest divisor of n, or report that it doesn't exist ...

  6. Educational Codeforces Round 37

    Educational Codeforces Round 37 这场有点炸,题目比较水,但只做了3题QAQ.还是实力不够啊! 写下题解算了--(写的比较粗糙,细节或者bug可以私聊2333) A. W ...

  7. Educational Codeforces Round 35 (Rated for Div. 2)

    Educational Codeforces Round 35 (Rated for Div. 2) https://codeforces.com/contest/911 A 模拟 #include& ...

  8. Educational Codeforces Round 59 (Rated for Div. 2) DE题解

    Educational Codeforces Round 59 (Rated for Div. 2) D. Compression 题目链接:https://codeforces.com/contes ...

  9. Educational Codeforces Round 32

    http://codeforces.com/contest/888 A Local Extrema[水] [题意]:计算极值点个数 [分析]:除了第一个最后一个外,遇到极值点ans++,包括极大和极小 ...

随机推荐

  1. Python学习笔记 - day13 - 进程与线程

    概述 我们都知道windows是支持多任务的操作系统. 什么叫“多任务”呢?简单地说,就是操作系统可以同时运行多个任务.打个比方,你一边在用浏览器上网,一边在听MP3,一边在用Word赶作业,这就是多 ...

  2. 网络设备之分配net_device结构

    注册网络设备时,会调用pci_driver->probe函数,以e100为例,最终会调用alloc_netdev_mqs来分配内存,并且在分配内存后调用setup函数(以太网为ether_set ...

  3. 采用dlopen、dlsym、dlclose加载动态链接库【转】

    转自:http://www.cnblogs.com/Anker/p/3746802.html 1.前言 为了使程序方便扩展,具备通用性,可以采用插件形式.采用异步事件驱动模型,保证主程序逻辑不变,将各 ...

  4. device tree 負值 property 寫法

    倘若你要設定 負值的property, 可能需要括符才會 build 過. 正確 decidegc = <(-10)>; 錯誤 decidegc = <-10>;

  5. 文字顺时针旋转90度(纵向)&古诗词排版

    1.文字旋转90度 width: 100px; height: 200px; line-height: 100px; text-align: center; writing-mode: vertica ...

  6. 如何在datepicker滚动完毕后触发事件去获得日期

    本来以为这件事情应该需要借助datepicker的委托来处理的,但是并没有找到此空间的委托. 其实最最简单的做法就是在IB中将次控件connect到一个Action上. 经过测试,当datepicke ...

  7. 1.Python3标准库--前戏

    Python有一个很大的优势便是在于其拥有丰富的第三方库,可以解决很多很多问题.其实Python的标准库也是非常丰富的,今后我将介绍一下Python的标准库. 这个教程使用的书籍就叫做<Pyth ...

  8. leetcode 之Gas Station(11)

    这题的思路很巧妙,用两个变量,一个变量衡量当前指针是否有效,一个衡量整个数组是否有解,需要好好体会. int gasStation(vector<int> &gas, vector ...

  9. 下载安装go插件包报错fatal: unable to access 'https://github.com/golang/tools.git/': OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054

    使用git命令来给vscode安装go插件的时候报错,如下: $ git clone https://github.com/golang/tools.git tools Cloning into 't ...

  10. MVC - 13.验证

    1.注解验证-Required-StringLength-Range-Regular. 1.1.验证方式 [Required], [StringLength], [Range], 和 [Regular ...