D. Vanya and Computer Game
time limit per test

2 seconds

memory limit per test

256 megabytes

input

standard input

output

standard output

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 test(s)
Input
4 3 2
1
2
3
4
Output
Vanya
Vova
Vanya
Both
Input
2 1 1
1
2
Output
Both
Both
Note

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.

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <sstream>
#include <queue>
#include <typeinfo>
#include <fstream>
typedef long long ll;
using namespace std;
//freopen("D.in","r",stdin);
//freopen("D.out","w",stdout);
#define sspeed ios_base::sync_with_stdio(0);cin.tie(0)
int dp[];
int main()
{
memset(dp,,sizeof(dp));
ll n,x,y;
cin>>n>>x>>y;
int flag2=;
int path1=;
int path2=;
int path=;
while()
{
if(path1==x&&path2==y)
break;
if(path1*y<path2*x)
{
dp[++path]=;
path1++;
}
else if(path1*y==path2*x)
{
dp[++path]=;
dp[++path]=;
path1++;
path2++;
}
else
{
dp[++path]=;
path2++;
}
//cout<<dp[path]<<endl;
}
while(n--)
{
ll shengming;
scanf("%I64d",&shengming);
shengming=shengming%(x+y);
if(shengming==x+y-||shengming==||dp[shengming]==)
printf("Both\n");
else if(dp[shengming]==)
{
if(flag2==)
printf("Vanya\n");
else
printf("Vova\n");
}
else
if(flag2==)
printf("Vova\n");
else
printf("Vanya\n");
}
return ;
}

Codeforces Round #280 (Div. 2) D. 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. 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 ...

  3. Codeforces Round #280 (Div. 2) E. Vanya and Field 数学

    E. Vanya and Field Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/492/pr ...

  4. Codeforces Round #280 (Div. 2) C. Vanya and Exams 贪心

    C. Vanya and Exams Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/492/pr ...

  5. Codeforces Round #280 (Div. 2)E Vanya and Field(简单题)

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud 本场题目都比较简单,故只写了E题. E. Vanya and Field Vany ...

  6. Codeforces Round #280 (Div. 2)_C. Vanya and Exams

    C. Vanya and Exams time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  7. Codeforces Round #280 (Div. 2) E. Vanya and Field 思维题

    E. Vanya and Field time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  8. Codeforces Round #280 (Div. 2) A. Vanya and Cubes 水题

    A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...

  9. 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table

    题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...

随机推荐

  1. python实现单单链表

    # -*- coding: utf-8 -*- # @Time : 2018/9/28 22:09 # @Author : cxa # @File : node.py # @Software: PyC ...

  2. image配准,发布geoserver服务

    1.arcmap配准:注:png只保留需要显示范围,多余部分删除,,配准后再进行栅格裁剪(为了去除偏移后出现的NoData值) 2.导出tif:注:NoData值设置,一般为256(有时候经过裁剪会默 ...

  3. 洛谷P2680运输计划

    传送门啦 要求的就是,把树上的一条边的权值设为0之后,所有路径中的最大值的最小值. 首先二分最大值,假设某次二分的最大值为x,我们首先找出所有大于x的路径(也就是我们需要通过改权缩短的路径),并把路径 ...

  4. java 使用内部类的理由

    每个内部类都能独立地继承自一个(接口的)实现,所以无论外围类是否已经继承了某个(接口的)实现,对于内部类都没有影响 内部类有效的实现了多重继承,也就是说,内部类允许继承多个非接口类型(类或抽象类) 如 ...

  5. hdu 5943(素数间隔+二分图匹配)

    Kingdom of Obsession Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Oth ...

  6. MST最小生成树

    首先,贴上一个很好的讲解贴: http://www.wutianqi.com/?p=3012 HDOJ 1233 还是畅通工程 http://acm.hdu.edu.cn/showproblem.ph ...

  7. Linux系统的优势

    熟悉电脑的人都知道,Linux 相比较于 Windows 有着众多的优势,所以现在越来越多的电脑用户开始使用 Linux 进行办公.学习.总体来讲,Linux 的优势主要有以下几个方面. 一.开源.免 ...

  8. Visual Studio 2013百度云下载地址

    Visual Studio 2013百度云下载地址: 链接: https://pan.baidu.com/s/1JkVYLnFo2TWSu4dkDdZP3Q  提取码: 关注公众号[获取   winf ...

  9. Java 之 JDBC

    mysql : //****** 四大金刚: 驱动类名.url.用户名.密码 //MySQL四大金刚 String driverClassname="com.mysql.jdbc.Drive ...

  10. 基于 SSH 框架的 Criteria 和 DetachedCriteria 多条件查询

    Hibernate 定义了 CriteriaSpecification 接口规范用来完成面向对象的条件查询,Criteria 和 DetachedCriteria 就是 CriteriaSpecifi ...