您的位置:首页 > 其它

Codeforces Round #280 (Div. 2)D. Vanya and Computer Game(二分)

2015-12-02 11:29 375 查看
题目链接

题意:A,B俩人一起打怪,A一秒打X次,B一秒打Y次,(每个人的攻击是对所有的怪物都有效果),每个怪物被打ai下就会死掉,问最后一下是谁打的。

解法 :A打一次是1/X 秒

B打一次是1/Y秒,浮点数不好计算,我们把二者乘以XY,那么

A打一次就是Y秒,B打一次就是X秒。然后二分怪物被打死的时间t.条件是t/X+t/Y>=a

#define CF
#ifndef CF
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<string>
#include<iostream>
#include<set>
#include<vector>
#else
#include<bits/stdc++.h>
#endif // CF
using namespace std;
#define LL long long
#define pb push_back
#define X first
#define Y second
#define cl(a,b) memset(a,b,sizeof(a))
typedef pair<long long ,long long > P;
const int maxn=100005;
const LL inf=1LL<<60;
const LL mod=1e9+7;

int main(){
LL n,x,y;
cin>>n>>x>>y;
for(int i=0;i<n;i++){
LL a;cin>>a;
LL l=0,r=1LL<<62;
while(l<=r){
LL mid=(l+r)/2;
if(mid/x+mid/y>=a)r=mid-1;
else l=mid+1;
}
if(l%x==0&&l%y==0)puts("Both");
else if(l%y==0)puts("Vanya");
else puts("Vova");
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: