【链接】 我是链接,点我呀:)

【题意】

题意

【题解】

第一个人攻击一次需要1/x秒
第二个人攻击一次需要1/y秒
这两个数字显然都是小数。
我们可以二分最后用了多少时间来攻击。
显然这个是有单调性的,攻击时间越多的话,攻击的次数也就越多。
假设二分出来攻击的时间是mid
那么攻击的次数就是
mid/(1/x) + mid/(1/y)
但是这样显然二分出来的也是一个小数。
我们完全没有办法根据二分出来的东西判断它到底是谁的倍数。
因此我们可以这样。
我们把第一个人攻击一次和第二个人攻击一次所需要的时间都乘上一个x*y
也就是说我们把秒这个单位换成了自己的一个单位t,而且t = x*y*秒
这样的话,
第一个人攻击一次需要的时间就是y t
第二个人攻击一次需要的时间就是x t
然后我们二分最后需要多少t的时间才够攻击a[i]次。
显然如果二分到mid了
那么攻击次数就是mid/y + mid/x
(如果不够整除的话,显然就已经不够敲一次了,所以向下取整就ok了)
然后根据最后二分出来的t值,如果同时是x和y的倍数的话,就是both,否则根据%x和%y的结果的出来最后一次是谁敲的就好了。
(这样涉及到的运算就都是整数的了)

【代码】

#include <bits/stdc++.h>
#define ll long long
using namespace std; const int N = 1e5; ll n,x,y; int main(){
ios::sync_with_stdio(0),cin.tie(0);
cin >> n >> x >> y;
while (n--){
ll cnt;
cin >> cnt;
ll l = 1,r = 1e16,temp = -1;
while (l<=r){
ll mid = (l+r)/2;
if (mid/y+mid/x>=cnt){
temp = mid;
r = mid - 1;
}else l = mid + 1;
}
if (temp%y==0 && temp%x==0){
cout<<"Both"<<endl;
}else if (temp%y==0){
cout<<"Vanya"<<endl;
}else {
cout<<"Vova"<<endl;
}
}
return 0;
}

【Codeforces 492D】Vanya and Computer Game的更多相关文章

  1. 【39.29%】【codeforces 552E】Vanya and Brackets

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  2. 【25.33%】【codeforces 552D】Vanya and Triangles

    time limit per test4 seconds memory limit per test512 megabytes inputstandard input outputstandard o ...

  3. 【30.23%】【codeforces 552C】Vanya and Scales

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  4. 【33.33%】【codeforces 552B】Vanya and Books

    time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...

  5. 【84.62%】【codeforces 552A】Vanya and Table

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【12.78%】【codeforces 677D】Vanya and Treasure

    time limit per test1.5 seconds memory limit per test256 megabytes inputstandard input outputstandard ...

  7. 【codeforces 415D】Mashmokh and ACM(普通dp)

    [codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...

  8. 【13.77%】【codeforces 734C】Anton and Making Potions

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  9. 【codeforces 762B】USB vs. PS/2

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

随机推荐

  1. 《windows核心编程系列》四谈谈进程的建立和终止

    第二部分:工作机理 第一章:进程 上一章介绍了内核对象,这一节开始就要不断接触各种内核对象了.首先要给大家介绍的是进程内核对象.进程大家都不陌生,它是资源和分配的基本单位,而进程内核对象就是与进程相关 ...

  2. Qt事件系统之一:Qt中的事件处理与传递

    一.简介 在Qt中,事件作为一个对象,继承自 QEvent 类,常见的有键盘事件 QKeyEvent.鼠标事件 QMouseEvent 和定时器事件 QTimerEvent 等,与 QEvent 类的 ...

  3. [Usaco2003 Open]Lost Cows

    Description N (2 <= N <= 8,000) cows have unique brands in the range 1..N. In a spectacular di ...

  4. 数论+DP HDOJ 4345 Permutation

    题目传送门 题意:一个置换群,经过最少k次置换后还原.问给一个N个元素,在所有的置换群里,有多少个不同的k. 分析:这道题可以转化成:N = Σ ai ,求LCM ( ai )有多少个不同的值.比如N ...

  5. Plugging an Unplugged Pluggable Database issue 3

    Multitenant Unplug/Plug Best Practices (文档 ID 1935365.1) 1.source 从0419 升级到1019 ,但是datapatch 没有回退041 ...

  6. AJPFX:递归与非递归之间的转化

    在常规表达式求值中: 输入为四则运算表达式,仅由数字.+.-.*./ .(.) 组成,没有空格,要求求其值. 我们知道有运算等级,从左至右,括号里面的先运算,其次是* ./,再是+.- : 这样我们就 ...

  7. Android BitmapFactory.decodeFile(filePath, options) 返回 Null 6.0权限

    今天在做拍照上传的时候遇到个问题,根据路径获取Bitmap 失败,一直返回空,以为这个路径获取Bitmap代码久经考验,不怀疑它,找参数传入是否正确,初步怀疑是 filePath 没传进去,打印 fi ...

  8. ubuntu服务器建立apache虚拟主机

    启用与停用站点的方法 a2ensite 站点名 a2dissite 站点名 基于名字的(通过域名来区分)的虚拟主机 安装好apache以后默认有一个叫default的虚拟主机.新建虚拟主机时可以直接复 ...

  9. cookie设置和读取以及获取超链接参数

    function setCookie(c_name, value, expiredays) { var exdate = new Date() exdate.setDate(exdate.getDat ...

  10. nodejs的学习

    nodejs 就是使用js来编写服务端的程序.它的特性是(单线程   速度快   耗内存多  异步   事件驱动) ( 一些技术的解决方案:默认情况下是 1.不支持多核,可以使用cluster 进行解 ...