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/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 2
1
2
3
4
Sample Output
Vanya
Vova
Vanya
Both
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=;i<n;i++)
{
long long a;scanf("%lld",&a);
long long l = ,r = 1LL<<;
while(l<=r)
{
long long mid = (l+r)/2LL;
if(mid/x+mid/y>=a)r=mid-;
else l=mid+;
}
if(l%x==&&l%y==)printf("Both\n");
else if(l%y==)printf("Vanya\n");
else printf("Vova\n");
}
}
Codeforces Round #280 (Div. 2) D. Vanya and Computer Game 二分的更多相关文章
- 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 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 ...
- 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 ...
- Codeforces Round #280 (Div. 2)E Vanya and Field(简单题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud 本场题目都比较简单,故只写了E题. E. Vanya and Field Vany ...
- 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 ...
- 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 ...
- 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 ...
- 水题 Codeforces Round #308 (Div. 2) A. Vanya and Table
题目传送门 /* 水题:读懂题目就能做 */ #include <cstdio> #include <iostream> #include <algorithm> ...
随机推荐
- 服务器安装Apache+Tomcat+Memcached共享Session的构架设计
网站集群部署解决计划 一. 计划目标 实现互动留言系统.后台发布系统的高可用性,有效解决高并发量对单台应用服务器的打击,确保应用服务器单点故障不影响系统正常运行. 二. 部署架 ...
- 面试题 IQ
现在有一大块金条,它可以分为七小块金条.是这样子的,工人为你工作7天,每天都将获得一小块金条,你要做的就是发工资,切割大块金条的次数最多两次,你有什么方法让工人每天都获得一小块金条呢?
- 【转】traits技术及模板偏特化
#include <iostream> using namespace std; struct __xtrue_type { }; // define two mark-type stru ...
- hdu 1198 Farm Irrigation
令人蛋疼的并查集…… 我居然做了大量的枚举,居然过了,我越来越佩服自己了 这个题有些像一个叫做“水管工”的游戏.给你一个m*n的图,每个单位可以有11种选择,然后相邻两个图只有都和对方连接,才判断他们 ...
- SQL点滴之编辑数据(转)
数据库中的数据编辑是我们遇到的最频繁的工作,这一个随笔中我来总结一下最常用的数据编辑. select into 经常遇到一种情况是,我们希望创建一个新表,表中的数据来源于原有的一个表:原有一个表,但是 ...
- Procdure for wanfo business report
CREATE OR REPLACE PROCEDURE PROC_TZ_EXEC_N_YEARREPORT(ssrq varchar2 ) as -----声明变量 v_raise EXCEPTION ...
- 【原】Storm Local模式和生产环境中Topology运行配置
Storm入门教程 1. Storm基础 Storm Storm主要特点 Storm基本概念 Storm调度器 Storm配置 Guaranteeing Message Processing(消息处理 ...
- Shell统计报表表格生成
基本需求 分析完数据后,一般需要将数据以附件的形式发送处理,这个已经在<>中有介绍,如何 用Python实现附件的发送. 但不是所有人都关心附件的内容,一般邮件中需要有些概要的信息,如附件 ...
- 【转】强大的vim配置文件,让编程更随意
原文地址:http://www.cnblogs.com/ma6174/archive/2011/12/10/2283393.html 花了很长时间整理的,感觉用起来很方便,共享一下. 我的vim配置主 ...
- Spring入门(10)-Spring JDBC
Spring入门(10)-Spring JDBC 0. 目录 JdbcTemplate介绍 JdbcTemplate常见方法 代码示例 参考资料 1. JdbcTemplate介绍 JdbcTempl ...