【cf492】D. Vanya and Computer Game(二分)
http://codeforces.com/contest/492/problem/D
有时候感觉人sb还是sb,为什么题目都看不清楚?
x per second, y per second...
于是我们二分second即可。
而且对每个monster都有伤害。。。。
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <iostream>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define for1(i,a,n) for(int i=(a);i<=(n);++i)
#define for2(i,a,n) for(int i=(a);i<(n);++i)
#define for3(i,a,n) for(int i=(a);i>=(n);--i)
#define for4(i,a,n) for(int i=(a);i>(n);--i)
#define CC(i,a) memset(i,a,sizeof(i))
#define read(a) a=getint()
#define print(a) printf("%d", a)
#define dbg(x) cout << (#x) << " = " << (x) << endl
#define error(x) (!(x)?puts("error"):0)
#define rdm(x, i) for(int i=ihead[x]; i; i=e[i].next)
inline const int getint() { int r=0, k=1; char c=getchar(); for(; c<'0'||c>'9'; c=getchar()) if(c=='-') k=-1; for(; c>='0'&&c<='9'; c=getchar()) r=r*10+c-'0'; return k*r; } int main() {
int n; ll x, y;
read(n); read(x); read(y);
for1(i, 1, n) {
ll a=getint();
ll l=0, r=1ll<<60, mid;
while(l<=r) {
mid=(l+r)>>1;
if(mid/x+mid/y>=a) r=mid-1;
else l=mid+1;
}
mid=r+1;
if(mid%x==0 && mid%y==0) puts("Both");
else if(mid%y==0) puts("Vanya");
else if(mid%x==0) puts("Vova");
}
return 0;
}
Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level. Vanya's character performs attack with frequency x hits per second and Vova's character performs attack with frequencyy hits per second. Each character spends fixed time to raise a weapon and then he hits (the time to raise the weapon is 1 / x seconds for the first character and 1 / y seconds for the second one). The i-th monster dies after he receives ai hits.
Vanya and Vova wonder who makes the last hit on each monster. If Vanya and Vova make the last hit at the same time, we assume that both of them have made the last hit.
The first line contains three integers n,x,y (1 ≤ n ≤ 105, 1 ≤ x, y ≤ 106) — the number of monsters, the frequency of Vanya's and Vova's attack, correspondingly.
Next n lines contain integers ai (1 ≤ ai ≤ 109) — the number of hits needed do destroy the i-th monster.
Print n lines. In the i-th line print word "Vanya", if the last hit on the i-th monster was performed by Vanya, "Vova", if Vova performed the last hit, or "Both", if both boys performed it at the same time.
4 3 2
1
2
3
4
Vanya
Vova
Vanya
Both
2 1 1
1
2
Both
Both
In the first sample Vanya makes the first hit at time 1 / 3, Vova makes the second hit at time 1 / 2, Vanya makes the third hit at time 2 / 3, and both boys make the fourth and fifth hit simultaneously at the time 1.
In the second sample Vanya and Vova make the first and second hit simultaneously at time 1.
【cf492】D. Vanya and Computer Game(二分)的更多相关文章
- Codeforces Round #280 (Div. 2) D. Vanya and Computer Game 二分
D. Vanya and Computer Game Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contes ...
- cf492D Vanya and Computer Game
D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces Round #280 (Div. 2) D. Vanya and Computer Game 预处理
D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces Round #280 (Div. 2) D. Vanya and Computer Game 数学
D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- CodeForces 492D Vanya and Computer Game (思维题)
D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- Codeforces 492D Vanya and Computer Game
D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input s ...
- 数论 - Vanya and Computer Game
Vanya and his friend Vova play a computer game where they need to destroy n monsters to pass a level ...
- 【Codeforces 492D】Vanya and Computer Game
[链接] 我是链接,点我呀:) [题意] 题意 [题解] 第一个人攻击一次需要1/x秒 第二个人攻击一次需要1/y秒 这两个数字显然都是小数. 我们可以二分最后用了多少时间来攻击. 显然这个是有单调性 ...
- CodeForces Round #280 (Div.2)
A. Vanya and Cubes 题意: 给你n个小方块,现在要搭一个金字塔,金字塔的第i层需要 个小方块,问这n个方块最多搭几层金字塔. 分析: 根据求和公式,有,按照规律直接加就行,直到超过n ...
随机推荐
- Android内存泄漏分析实战
内存泄漏简单介绍 java能够保证当没有引用指向对象的时候,对象会被垃圾回收器回收.与c语言自己申请的内存自己释放相比,java程序猿轻松了非常多.可是并不代表java程序猿不用操心内存泄漏.当jav ...
- Unity Web前端研究
原地址:http://blog.csdn.net/libeifs/article/details/7200630 开发环境 Window7 Unity3D 3.4.1 MB525defy Andro ...
- MSSQL查找前一天,前一月,前一年的数据,对比当前时间记录查找超过一年,一月,一天的数据
,') ,GETDATE()) ,') ,GETDATE()) ,') ,GETDATE()) ,GETDATE())) ,GETDATE())) ,GETDATE()))
- 谋哥:我跟CEO们都说了啥
昨天,我和谋天团会员杨过(cdywq7070)--杨总,聊他公司的App,针对女性社交的"闪聊". 杨总增加谋天团,主要是想让我帮他策划推广,我说你让我策划一次.还不如增加谋天团. ...
- git配置用户名邮箱
通常会配置全局的 用户名 邮箱 例如 姓名@公司邮箱 姓名 git config --global user.name "姓名" git config --global use ...
- Python title() 方法
描述 Python title() 方法返回"标题化"的字符串,就是说所有单词都是以大写开始,其余字母均为小写. 语法 title() 方法语法: S.title() 参数 无. ...
- sim800L调试问题
SIM800L默认上电开机,若此时没有把rst和pwk引脚提前设置好,SIM800l会使stm32进入硬件中断(这可能是因为方面电源的原因导致的),同时sim800L开机后需要一定的时间稳定下来,建议 ...
- Node.js开发入门—使用cookie保持登录
这次来做一个站点登录的小样例,后面会用到. 这个演示样例会用到Cookie.HTML表单.POST数据体(body)解析. 第一个版本号,我们的用户数据就写死在js文件中. 第二个版本号会引入Mong ...
- Cocos2d-x 3.4 初体验——安装教程
电脑系统window7 32位 1.首先从官网下载cocos2d-x并解压 http://cn.cocos2d-x.org/download/ 解压后的文件夹中有一个setup.py,双击运行.需要安 ...
- Mac里面如何设置自启动服务
Mac OS x 启动项设置 Mac OS X的启动原理: 1,mac固件激活,初始化硬件,加载BootX引导器. 2,BootX加载内核与内核扩展(kext). 3,内核启动launchd进程. 4 ...