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. 任务调度框架kunka

    kunka kunka是一个任务调度框架.用户只需要在Task接口中实现自己要执行的功能,并且选择合适的执行器,放入TaskManager中,就可以了完成整个任务了. 实现细节 整个任务信息存放在内存 ...

  2. 004 ConcurrentHashMap原理

    下面这部分内容转载自: http://www.haogongju.net/art/2350374 JDK5中添加了新的concurrent包,相对同步容器而言,并发容器通过一些机制改进了并发性能.因为 ...

  3. 关于进度管理工具Gantt图

    关于进度管理工具Gantt图 18.以下关于进度管理工具图的叙述中,不正确的是( D). A.能清晰地表达每个任务的开始时间.结束时间和持续时间 B.能清晰地表达任务之间的并行关系 C.不能清晰地确定 ...

  4. ASP.NET Core学习链接

    https://www.cnblogs.com/artech/p/dependency-injection-in-asp-net-core.html http://www.cnblogs.com/ar ...

  5. 【转载】viewLoad、viewDidLoad的一些事

    viewLoad和viewDidLoad都可以用来在视图载入的时候,初始化一些内容 viewDidLoad此方法只有当view从nib文件初始化的时候才被调用.viewDidLoad用于初始化,加载时 ...

  6. Genymotion的2个问题及解决方法

    问题一:Unable to connect to your virtual device 解决方法:基本都是内存不够导致的,在virtualbox中调整对应虚拟机的内存,确保任务管理器中的性能一项中剩 ...

  7. 2.Spark Streaming运行机制和架构

    1 解密Spark Streaming运行机制 上节课我们谈到了技术界的寻龙点穴.这就像过去的风水一样,每个领域都有自己的龙脉,Spark就是龙脉之所在,它的龙穴或者关键点就是SparkStreami ...

  8. vue-music 关于Player (播放器组件)--播放模式

    播放器播放模式有三种,顺序播放,单曲循环,随机播放,定义在vuex 中的字段为 mode.点击切换播放模式的图标.切换模式判断是否为随机播放,如果是随机播放模式,则取得sequenceList 列表数 ...

  9. MFC获取句柄

    CWnd *pWnd = GetDlgItem(ID_***); // 取得控件的指针 HWND hwnd = pWnd->GetSafeHwnd(); // 取得控件的句柄

  10. STL容器 -- Priority_Queue

    核心:和队列相似,但优先队列中的 “下一个元素” 指的是 “优先级最高” 的元素. 头文件:#include<queue> 普通类型的构造方法: priority_queue<int ...