现在的位置: 首页 > 综合 > 正文

CF – round # 280 – D

2019年04月03日 ⁄ 综合 ⁄ 共 767字 ⁄ 字号 评论关闭
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
const int maxn = 100005;
LL gcd(LL a,LL b){
return  b==0 ? a : gcd(b,a%b);
}
LL lcm(LL a,LL b){
return a*b/gcd(a,b);
}
struct node{
LL x,y;
node(LL x=0,LL y=0):x(x),y(y){}
bool operator < (const node& rhs) const{
return y < rhs.y;
}
};
const int N = 2050000;
int id[N];
node ans[N];
int main()
{
  LL n,x,y;
  cin>>n>>x>>y;
  LL g = gcd(x,y);
  LL  ll = (x*y)/g;
  LL nx = ll/x , ny=ll/y;
  LL L = lcm(nx,ny);
  int T = L/nx + L/ny;
  int kk=0;
  for(LL j=nx;j<=L;j+=nx) ans[kk++]=(node(1,j));
  for(LL j=ny;j<L;j+=ny)  ans[kk++]=(node(2,j));
  sort(ans,ans+kk);
  for(int i=1;i<T;i++){
     id[i] = ans[i-1].x;
  }
  for(int i=1;i<=n;i++){
    int te; scanf("%d",&te);
    te = te%T;
    if(te == 0 || te == T-1) printf("Both\n");
    else {id[te] == 1 ? printf("Vanya\n") :printf("Vova\n");
    }
  }
  return 0;
}

抱歉!评论已关闭.