【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 ...
随机推荐
- Ubuntu install and uinstall
一.Ubuntu中软件安装方法 1.APT方式 (1)普通安装:apt-get install softname1 softname2 -; (2)修复安装:apt-get -f install so ...
- Retinex系列之Frankle-McCann Retinex 分类: Matlab 图像处理 2014-12-01 21:52 538人阅读 评论(2) 收藏
一.Frankle-McCann Retinex Frankle-McCann算法选择一条螺旋结构的路径用于像素间的比较.如下图,算法沿着螺旋路径选取用于比较 像素点,这种路径选择包含了整个图像的全局 ...
- java数组实现买彩票(阿基老师的打乱排序思想)
package com.wh.array; public class Lottery { public static void main(String[] args) { int[] num=new ...
- 安装SNMP
http://songknight.blog.51cto.com/2599480/655337
- 使用 JSX 描述 UI 信息
这一节我们通过一个简单的例子讲解 React.js 描述页面 UI 的方式.把 src/index.js 中的代码改成: import React, { Component } from 'react ...
- js跨域请求的5中解决方式
跨域请求数据解决方案主要有如下解决方法: ? 1 2 3 4 5 JSONP方式 表单POST方式 服务器代理 Html5的XDomainRequest Flash request 分开说明: 一.J ...
- (2)《Head First HTML与CSS》学习笔记---img与基于标准的HTML5
1.浏览器处理图像的过程: 1.服务器获取文件,显示出文本结构,以及预留默认的大小给<img>(如果该<img>有width-1值和height-1值,则根据这个值提前设好页面 ...
- Android SDK镜像更新网速慢的解决问题
通过更换代理解决 Android SDK 在线更新镜像服务器资源:大连东软信息学院镜像服务器地址:http://mirrors.neusoft.edu.cn 端口:80北京化工大学镜像服务器地址:IP ...
- 有意思的String字符工具类
对String的操作是Java攻城师必备的,一个优秀的攻城师是懒惰,他会把自己的一些常见的代码写成可提供拓展和复用的工具类或者工具库,这些是这些优秀工程师的法宝. 我就先从String这个基本操作开始 ...
- Javaweb项目构建常见问题
eclipse中 将java项目转换为web项目 1.找到项目工作空间目录,打开.project文件,并修改文件, 修改如下: 找到:<natures> </natures ...