【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 ...
 
随机推荐
- 一次安装win10 ubuntu16.0经过记录
			
步骤摘要 三个U盘: 1.制作WIN8 PE启动盘,使用的软件为“U深度装机版”,可自行百度下载 2.制作WIN10系统安装盘,使用UltraISO,这里使用的win10镜像为: 链接: http:/ ...
 - Session 简单购物车
			
package session.test; import java.io.IOException; import java.io.PrintWriter; import java.util.Linke ...
 - 【JS】jQuery中将数组转换成字符串join()和push()使用
			
1.push()将元素依次添加至数组:2.join()将数组转换成字符串,里面可以带参数分隔符,默认[,] <script type = text/javascript> $(docume ...
 - brew install memcache get Error: Formulae found in multiple taps
			
本篇文章由:http://xinpure.com/brew-install-memcache-get-error-formulae-found-in-multiple-taps/ 安装环境: Mac ...
 - RBAC权限设计实例(转)
			
实现业务系统中的用户权限管理 B/S系统中的权限比C/S中的更显的重要,C/S系统因为具有特殊的客户端,所以访问用户的权限检测可以通过客户端实现或通过客户端+服务器检测实现,而B/S中,浏览器是每一台 ...
 - JAVA中==与equals的区别
			
equals如果没有被重写的话,和==的作用是一样的,都是判断两个对象引用是否指向同一个地址.一般重写了equals()方法就表示比较它们“实际意义上相等”,比较的是内容,而不是引用地址.Java中S ...
 - mac 系统使用macaca inspector 获取iphone真机应用元素
			
1.安装brew 软件包管理工具:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/inst ...
 - C union共用体
			
共用体是一种特殊的数据类型,允许您在相同的内存位置存储不同的数据类型.您可以定义一个带有多成员的共用体,但是任何时候只能有一个成员带有值.共用体提供了一种使用相同的内存位置的有效方式. 共用体定义: ...
 - (Xilinx)FPGA中LVDS差分高速传输的实现
			
https://wenku.baidu.com/view/24e8bad86f1aff00bed51ef8.html
 - verilog之四位全加器的编译及仿真(用开源免费的软件——iverilog+GTKWave)
			
verilog之四位全加器的编译及仿真(用开源免费的软件——iverilog+GTKWave) 四位全加器的verilog的代码比比皆是,这里上一个比较简单的: /* 4位全加器全加器需要有输入输出, ...