D. Vanya and Computer Game

Time Limit: 20 Sec

Memory Limit: 256 MB

题目连接

http://codeforces.com/contest/492/problem/D

Description

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

4 3 21234

Sample Output

VanyaVovaVanyaBoth

HINT

题意

Vanya每秒钟可以砍x刀,Vova每秒可以砍y刀

有n次询问,给你一个怪兽的血量为ai,然后问你最后一刀是谁补的刀

同时补刀,输出Both

题解:

二分是多少s砍死这只怪兽

然后再check就好一下了~

代码

#include<iostream>
#include<stdio.h>
using namespace std;int main()
{int n;long long x,y;scanf("%d%lld%lld",&n,&x,&y);for(int i=0;i<n;i++){long long a;scanf("%lld",&a);long long l = 0,r = 1LL<<60;while(l<=r){long long mid = (l+r)/2LL;if(mid/x+mid/y>=a)r=mid-1;else l=mid+1;}if(l%x==0&&l%y==0)printf("Both\n");else if(l%y==0)printf("Vanya\n");else printf("Vova\n");}
}

Codeforces Round #280 (Div. 2) D. Vanya and Computer Game 二分相关推荐

  1. Codeforces Round #280 (Div. 2)

    B. Vanya and Lanterns 题意:给出n个路灯,街道的长度,求出路灯的最小照射半径,使得整条街道都被照亮. 求出起点到第一盏灯的距离---n盏灯之间的距离/2---最后一盏灯到街尾的距 ...

  2. CodeForces Round #280 (Div.2)

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

  3. Codeforces Round #355 (Div. 2) B. Vanya and Food Processor 水题

    B. Vanya and Food Processor 题目连接: http://www.codeforces.com/contest/677/problem/B Description Vanya ...

  4. Codeforces Round #308 (Div. 2) C. Vanya and Scales dfs

    题目链接: http://codeforces.com/contest/552/problem/C 题意: 给你100个砝码,第i个砝码质量是w^i,然后问你能不能在有m的情况下,左边和右边都放砝码, ...

  5. Codeforces Round #355 (Div. 2) D. Vanya and Treasure dp+分块

    题目链接: http://codeforces.com/contest/677/problem/D 题意: 让你求最短的从start->...->1->...->2->. ...

  6. Codeforces Round #700 (Div. 2) C. Searching Local Minimum 交互二分

    传送门 题意: 给一个数组,让你找到a[i]<min(a[i+1],a[i−1])a[i]<min(a[i+1],a[i-1])a[i]<min(a[i+1],a[i−1])位置ii ...

  7. Codeforces Round #703 (Div. 2) Guessing the Greatest C1 C2 二分

    link 题意:交互题,每次可以询问一个区间的次大值,保证所有值都不相同,求最大值位置.easy是询问最多40次,hard最多20次. 交互题大部分都是二分,可以向二分考虑. easy比较好想,假设当 ...

  8. Codeforces Round #223 (Div. 2): C. Sereja and Prefixes(二分+递归)

    题意: 你有一个序列,一开始为空,之后进行m次操作,操作有两种: 1 x:在当前序列后面添加一个数x 2 x, y:将序列的前x个数复制y遍接序列后面(x<10000) 之后n次询问,每次询问位 ...

  9. Codeforces Round #703 (Div. 2)C1C2 Guessing the Greatest(二分)

    题意: 交互题. query l,r区间内第二大的数,要求得到整个数组最大的数. 思路:首先我们对整体数组进行query 找到第二大的数所在的位置,设这个位置为p. 然后分别对[1,p]和[p,n]进 ...

最新文章

  1. 测试openssl_encrypt
  2. 【计算机网络】网络层 : IPv4 地址 ( IP 地址分类 | 特殊 IP 地址 | 私有 IP 地址 | A 类、B 类、C 类 IP 地址网络号主机号数量 )★
  3. ALV输出无法指定STATUS
  4. Question for the 3D printing lattice?
  5. 为什么民航单位免费给查胸部CT+为什么天气预报中有风向
  6. myeclipse深色模式_完善深色模式的调色板
  7. Spring中的@Value注解详解
  8. python怎么制作游戏图片_【图片】从0开始学用Python做游戏的全过程【精品贴】(不定期更新)【python吧】_百度贴吧...
  9. oracle日期大于3个月,用三个月时间做oracle实验,养成实验习惯
  10. Python整理PEER所下载的地震波源数据——提取地震波至txt+生成地震波反应谱
  11. 【Spring笔记09】Spring中事务传播机制(注解方式)
  12. 网络安全建设网络可用性管理方法
  13. 小米摄像头修改wifi
  14. 2019烟台计算机副高职称报名时间,烟台市公共企事业单位信息公开 政策文件 2019年度职称评审工作日程安排...
  15. 计算机桌面图标多一个箭头,怎么去掉电脑桌面图标箭头(一个小妙招解决win图标小箭头)...
  16. page loading strategy
  17. 领域驱动设计(domain driven design)战略篇之一 战略 Bounded Context
  18. Minecraft 1.16.5模组开发(三十一) 自定义建筑生成(structure) (新)
  19. 利用python读取excel中的公司名称获取公司的经营范围并回填进excel中
  20. 菜鸟在学编程__LSJ

热门文章

  1. 【bzoj 入门OJ】[NOIP 热身赛]Problem C: 星球联盟(并查集)
  2. JVM笔记7:类加载器
  3. 利用Enterprise Library中的DAAB构造的数据库访问架构
  4. 反卷积可视化工具--deconv-deep-vis-toolbox
  5. 数据结构上机实践第三周项目1
  6. Tesseract试用过程及结果分析
  7. 常见经典排序算法学习总结(插入、shell、冒泡、选择、归并、快排等)
  8. python百度语音实时识别成文字_python 上传百度语音识别+文字返回结果
  9. 高度为5的3阶b树含有的关键字个数_B-树和B+树的应用:数据搜索和数据库索引...
  10. java为table添加一行_Js实现Table动态添加一行的小例子