CF - round # 280 - D
2014-12-02 03:19
134 查看
#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 ; node ans ; 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; }
相关文章推荐
- CF#280 (Div. 2) A.(找规律)
- codeforces 280,281(Round #172)题解
- CF 280B. Vanya and Lanterns(div2)
- 机器学习4 CF推荐算法
- cf C. Wilbur and Points (STL_vector)
- CF - Profact(DFS + 剪枝)
- iOS进程间通信之CFMessagePort
- CF-Approximating a Constant Range
- 让人崩溃的Californium (Cf) CoAP framework ,总算解决,可以调试
- CF 335 div.2-C/div.1-A/605A Sorting Railway Cars
- 再谈容器标准:CoreOS 总结 OCI、CNCF 和 AppC 的发展
- CF Good Bye 2015 C- New Year and Domino(CF611C)
- reason: '-[__NSCFString replaceOccurrencesOfString:withString:options:range:]: Range {0, 6} out of b
- CF 10C Digital Root
- cf#Wunder Fund Round 2016 -A - Slime Combining-简单数学
- cf#AIM Tech Round -B. Making a String-贪心/set
- CF 604B More Cowbell#贪心
- CF 96A Football
- CFSocket相关(未完待续)
- CF 631D KMP/Z