题意:有N只怪物,每只的血量为Ai,现在有两个人攻击力都为1,Vanya攻速为1秒X下,Vova攻速为每秒Y下,问每只怪物最后是被谁杀死的,如果一起打出最后一下,输出Both。
范围:N<=10的5次,X,Y<=10的6次,Ai<=10的9次
解法:二分很容易想到,只要二分是什么时刻打死怪物就好了,只是数据非常恶心,十分难AC,尝试了各种姿势才A..
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<iostream>
#include<stdlib.h>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<bitset>
#pragma comment(linker, "/STACK:1024000000,1024000000")
template <class T>
bool scanff(T &ret){ //Faster Input
char c; int sgn; T bit=0.1;
if(c=getchar(),c==EOF) return 0;
while(c!='-'&&c!='.'&&(c<'0'||c>'9')) c=getchar();
sgn=(c=='-')?-1:1;
ret=(c=='-')?0:(c-'0');
while(c=getchar(),c>='0'&&c<='9') ret=ret*10+(c-'0');
if(c==' '||c=='\n'){ ret*=sgn; return 1; }
while(c=getchar(),c>='0'&&c<='9') ret+=(c-'0')*bit,bit/=10;
ret*=sgn;
return 1;
}
#define inf 1073741823
#define llinf 4611686018427387903LL
#define PI acos(-1.0)
#define lth (th<<1)
#define rth (th<<1|1)
#define rep(i,a,b) for(int i=int(a);i<=int(b);i++)
#define drep(i,a,b) for(int i=int(a);i>=int(b);i--)
#define gson(i,root) for(int i=ptx[root];~i;i=ed[i].next)
#define tdata int testnum;scanff(testnum);for(int cas=1;cas<=testnum;cas++)
#define mem(x,val) memset(x,val,sizeof(x))
#define mkp(a,b) make_pair(a,b)
#define findx(x) lower_bound(b+1,b+1+bn,x)-b
#define pb(x) push_back(x)
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
int n;
double x,y;
double eps=1e-6;
void getans(double val){
double l=0.0,r=val/max(x,y)+eps;
rep(i,1,100){
double m=(l+r)/2.0;
if(floor(m*x)+floor(m*y)>=val)r=m;
else l=m;
}
double xx=floor(l*x+eps);
double yy=floor(l*y+eps);
if(xx*y==yy*x)printf("Both\n");
if(xx*y>yy*x)printf("Vanya\n");
if(xx*y<yy*x)printf("Vova\n");
}
int main(){
scanff(n);
scanff(x);
scanff(y);
rep(i,1,n){
double temp;
scanff(temp);
getans(temp);
}
}