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

【题意】

题意

【题解】

第一个人攻击一次需要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. shell脚本从入门到精通

    阿里云大学 shell脚本从入门到精通 第1 章 : shell脚本编程-变量-算术表达式-判断语句-if分支语句 第2 章 : case-for-While-双括号-循环嵌套-break-conti ...

  2. ACM配置指南

    Ubuntu桌面入门指南 ACM比赛系统ubuntu 使用指南 ACM核武器 简明 Vim 练级攻略 Vim命令合集 代码编辑神器VIM(附我写acm程序时的配置) my_vimrc in ubunt ...

  3. Service官方教程(9)绑定服务时的注意事项

    Binding to a Service Application components (clients) can bind to a service by calling bindService() ...

  4. 设置UITableViewCell 选中时的背景颜色

    自定义Cell如图 一个View上面放了四个Label 分别连线到.m文件中 @property (weak, nonatomic) IBOutlet UILabel *nameLabel; @pro ...

  5. jmeter(五)集合点

    集合点: 简单来理解一下,虽然我们的“性能测试”理解为“多用户并发测试”,但真正的并发是不存在的,为了更真实的实现并发这感念,我们可以在需要压力的地方设置集合点,每到输入用户名和密码登录时,所有的虚拟 ...

  6. 面相切面编程AOP以及在Unity中的实现

    一.AOP概念 AOP(Aspect-Oriented Programming,面向切面的编程),它是可以通过预编译方式和运行期动态代理实现在不修改源代码的情况下给程序动态统一添加功能的一种技术.它是 ...

  7. colormap画出的图不是彩色问题

    针对matlab2017渲染出的彩色图是黑白的问题. t=labels; t(tstSet(:,end-))=Relabels; t=reshape(t,,); t=t'; figure imshow ...

  8. TinyMCE编辑器

    TinyMCE编辑器下载地址   http://www.tinymce.com/download/download.php

  9. asterisk-java ami3 属性改变监听

    asteriskServer.addAsteriskServerListener(new AsteriskListenerInit());//服务属性监听会自动连接服务 实现AsteriskServe ...

  10. iTOP-4418/6818开发板支持双屏异显,双屏同显

    iTOP-4418/6818开发板平台安卓系统下支持双屏异显,双屏同显,客户可按照不同用途,分别播放适合屏幕显示方式的内容 ,如HDMI屏幕和LCD屏幕显示不同内容, 一个屏幕播放广告,另一个屏幕运行 ...