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 frequency y 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.

Input

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.

Output

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.

Sample Input

Input
4 3 2
1
2
3
4
Output
Vanya
Vova
Vanya
Both
Input
2 1 1
1
2
Output
Both
Both

Hint

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.

--------------------------------------------------------------我是分割线^_^-------------------------------------------------------------------

题意:A,B俩人一起打怪,A一秒打X次,B一秒打Y次,(每个人的攻击是对所有的怪物都有效果),每个怪物被打ai下

就会死掉,问最后一下是谁打的。

解法 :A打一次是1/X 秒 B打一次是1/Y秒,浮点数不好计算,我们把二者乘以XY,那么 A打一次就是Y秒,B打一次就是

X秒。然后二分怪物被打死的时间t.条件是t/X+t/Y>=a。

实际上是比例的问题,题意中A是1/x秒打一次,而B是1/y打一次,比例是1/x :1/y,可以两边都乘以xy,比例化为y:x,

意思是A打一次需要y秒,而B打一次需要x秒,注意乘以之后数据范围的变化,已经超过题目所给的1e9了,所以二分枚举

时间的时候要特别注意这一点= =。

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<cctype>
using namespace std; #define Int __int64
#define INF 0x3f3f3f3f const int MAXN = 111111;
Int num[MAXN];
Int n, x, y; bool Judge(Int mid, Int m) {
Int s = mid / x + mid / y;
if (s >= m) return true;
else return false;
}
int main()
{
//freopen("input.txt", "r", stdin); while (scanf("%I64d %I64d %I64d", &n, &x, &y) != EOF) {
for (int i = 0; i < n; i++) {
scanf("%I64d", &num[i]);
}
for (int i = 0; i < n; i++) {
Int lower = 1, higher = 1e16;
while (lower <= higher) {
Int mid = (lower + higher) / 2;
bool ok = Judge(mid, num[i]);
if (ok) higher = mid - 1;
else lower = mid + 1;
}
Int s = lower;
if (s % x == 0 && s % y == 0) {
printf("Both\n");
} else if (s % x == 0) {
printf("Vova\n");
} else {
printf("Vanya\n");
}
}
}
return 0;
}

数论 - Vanya and Computer Game的更多相关文章

  1. 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 ...

  2. cf492D Vanya and Computer Game

    D. Vanya and Computer Game time limit per test 2 seconds memory limit per test 256 megabytes input s ...

  3. 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 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. 【cf492】D. Vanya and Computer Game(二分)

    http://codeforces.com/contest/492/problem/D 有时候感觉人sb还是sb,为什么题目都看不清楚? x per second, y per second... 于 ...

  8. 【Codeforces 492D】Vanya and Computer Game

    [链接] 我是链接,点我呀:) [题意] 题意 [题解] 第一个人攻击一次需要1/x秒 第二个人攻击一次需要1/y秒 这两个数字显然都是小数. 我们可以二分最后用了多少时间来攻击. 显然这个是有单调性 ...

  9. CodeForces Round #280 (Div.2)

    A. Vanya and Cubes 题意: 给你n个小方块,现在要搭一个金字塔,金字塔的第i层需要 个小方块,问这n个方块最多搭几层金字塔. 分析: 根据求和公式,有,按照规律直接加就行,直到超过n ...

随机推荐

  1. php中session锁--如何防止阻塞请求(译)

    现代浏览器限制到一个host并发连接的数量一般为4或6.这意味着,如果您的web页面加载几十个来自同一个host的assert file(js.图像.css)时,由于并发数的限制,会产生排队.同样甚至 ...

  2. 探索ASP.NET MVC框架之控制器的查找与激活机制

    引言 前面一篇博文我们介绍了MVC框架的路由机制,我们知道一个URL请求如何从ASP.NET处理管线到达了IHttpHandler实例(MvcHandler).今天我们从MvcHandler来进行下一 ...

  3. SpringMVC配置拦截器实现登录控制

    SpringMVC读取Cookie判断用户是否登录,对每一个action都要进行判断.之前使用jstl标签在页面上判断session如果没有登录就使用如下代码跳转到登录页面. <c:if tes ...

  4. js高级群的一些整理6月

    https://github.com/the5fire/backbonejs-learning-note/blob/master/chapters/01-hello-backbonejs.rst Ba ...

  5. toolkit --------chart属性

    Data Visualization类组件以直观的图表方式显示数据的分布,能够让我们更好地分析各数据的内在联系.本文主要向大家介绍该类组件的基本特性以及使用实例. 一.基本特性介绍 1.chart组件 ...

  6. Java Native Interfce三在JNI中使用Java类的普通方法与变量

    本文是<The Java Native Interface Programmer's Guide and Specification>读书笔记 前面我们学习了如何在JNI中通过参数来使用J ...

  7. 【Python基础学习二】定义变量、判断、循环、函数基本语法

    先来一个愉快的Hello World吧,就是这么简单,不需要写标点符号,但是需要严格按照缩进关系,Python变量的作用域是靠tab来控制的. print("Hello World" ...

  8. Qt应用程序图标设置

    Qt应用程序图标设置 本文仅仅适用于windows下,linux等不适用. 下面说的图标,指的是程序文件的图标,而不是托盘图标或者说运行时任务栏的图标(任务栏和程序窗口的图标在windows/linu ...

  9. Mac键盘图标与对应快捷按键标志汇总

    Mac键盘图标与对应快捷按键 ⌘--Command () win键 ⌃ --Control ctrl键 ⌥--Option (alt) ⇧--Shift ⇪--Caps Lock fn--功能键就是 ...

  10. 服务器监控之 Monitorix 初体验

    参考: http://www.tecmint.com/monitorix-a-lightweight-system-and-network-monitoring-tool-for-linux/ Cen ...