【Codeforces 492D】Vanya and Computer Game
【链接】 我是链接,点我呀:)
【题意】
题意
【题解】
第一个人攻击一次需要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的更多相关文章
- 【39.29%】【codeforces 552E】Vanya and Brackets
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【25.33%】【codeforces 552D】Vanya and Triangles
time limit per test4 seconds memory limit per test512 megabytes inputstandard input outputstandard o ...
- 【30.23%】【codeforces 552C】Vanya and Scales
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【33.33%】【codeforces 552B】Vanya and Books
time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard ou ...
- 【84.62%】【codeforces 552A】Vanya and Table
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【12.78%】【codeforces 677D】Vanya and Treasure
time limit per test1.5 seconds memory limit per test256 megabytes inputstandard input outputstandard ...
- 【codeforces 415D】Mashmokh and ACM(普通dp)
[codeforces 415D]Mashmokh and ACM 题意:美丽数列定义:对于数列中的每一个i都满足:arr[i+1]%arr[i]==0 输入n,k(1<=n,k<=200 ...
- 【13.77%】【codeforces 734C】Anton and Making Potions
time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 762B】USB vs. PS/2
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
随机推荐
- Spring中bean的五个作用域简介(转载)
Spring上个版本的IoC容器支持两个不同的bean作用域(单例与原型).Spring 2.0改进了这一点,不仅提供了一些依赖于Spring部署环境(比如说,在web环境中的request和sess ...
- 转 PHP Cookies
cookie 常用于识别用户. 什么是 Cookie? cookie 常用于识别用户.cookie 是服务器留在用户计算机中的小文件.每当相同的计算机通过浏览器请求页面时,它同时会发送 cookie. ...
- OAuth 开放授权 Open Authorization
http://oauth.net/ http://tools.ietf.org/html/rfc6749 http://reg.163.com/help/help_oauth2.html 网易通行证O ...
- outlook 通讯录分类--2017年1月16日--对联系人分类管理
outlook功能多,复杂,导致打开界面就晕,通讯录分类 问:在Outlook 中,随着联系人数量的增多,亲朋好友.同事.客户的信息混杂在一起,每次发邮件都要用很长时间才能从联系人列表中找到需要的人. ...
- Vue.js学习笔记--1.基础HTML和JS属性的使用
整理自官网教程 -- https://cn.vuejs.org/ 1. 在HTML文件底部引入Vue <script src="https://cdn.jsdelivr.net/npm ...
- 掌握Spark机器学习库-07-随机梯度下降
1)何为随机梯度下降 优化方法 迭代更新,来寻找函数全局最优解的方法 与最小二乘法相比:适用于变量众多,模型更复杂 2)梯度 变化最快,“陡峭” 通过函数表达式来衡量梯度 3)随机梯度下降原理推导过程 ...
- CentOS 7 配置本地yum 源
1. 加载 CentOS的ISO镜像并挂载: [root@localhost files]# mount /media/files/CentOS-7-x86_64-DVD-1611.iso /mnt/ ...
- 迅为八核cortex a53开发板android/linux/Ubuntu系统
详情请点击了解:http://www.topeetobard.com 店铺:https://arm-board.taobao.com 核心板: 提供1G和2G内存版本,全机器焊接,杜绝手工,批量无忧. ...
- C# GDI+ 画坐标(x,y)
private void button1_Click(object sender, EventArgs e) { Graphics g = this.CreateGraphics(); g.Clear ...
- 关于TreeView控件的TreeNodeCheckChanged事件无法回发处理
1.在后台设置属性 TreeView1.Attributes.Add("onclick", "postBackByObject()"); 2.在前台页面中间添加 ...