Codeforces Round #292 (Div. 2)——B——Drazil and His Happy Friends
2015-03-19 13:00
387 查看
Drazil has many friends. Some of them are happy and some of them are unhappy. Drazil wants to make all his friends become happy. So he invented the following plan.
There are n boys and m girls among his friends. Let's number them from 0 to n - 1 and 0 to m - 1 separately. In i-th day, Drazil invites
View Code
There are n boys and m girls among his friends. Let's number them from 0 to n - 1 and 0 to m - 1 separately. In i-th day, Drazil invites
#include<cstdio> #include<cstring> #include<algorithm> #include<iostream> using namespace std; int n,m,h,g,x; int a[1100],b[1100]; int main() { while(~scanf("%d%d",&n,&m)){ memset(a,0,sizeof(a)); memset(b,0,sizeof(b)); scanf("%d",&h); for(int i = 1; i <= h ; i++){ scanf("%d",&x); a[x] = 1; } scanf("%d",&g); for(int i = 1; i <= g; i++){ scanf("%d",&x); b[x] = 1; } int t = max(n,m); for(int i = 0 ; i <= t*1000; i++){ if(a[i%n] == 1){ b[i%m] = 1; continue; } if(b[i%m] == 1) a[i%n] = 1; } int flag = 0; for(int i = 0; i < n; i++){ if(a[i] == 0) flag = 1; } for(int i = 0; i < m ; i++){ if(b[i] == 0 ) flag = 1; } if(flag) printf("No\n"); else printf("Yes\n"); } return 0; }
View Code
相关文章推荐
- Codeforces Round #292 (Div. 1) C. Drazil and Park
- Codeforces Round #292 (Div. 2) C. Drazil and Factorial(贪心YY)
- Codeforces Round #292 (Div. 2)——A——Drazil and Date
- Codeforces Round #292 (Div. 2) -- A. Drazil and Date
- Codeforces Round #292 (Div. 2) A. Drazil and Date
- Codeforces Round #292 (Div. 1) B. Drazil and Tiles (类似拓扑)
- Codeforces Round #292 (Div. 2)D. Drazil and Tiles
- Codeforces Round #292 (Div. 1) - B. Drazil and Tiles
- Codeforces Round #292 (Div. 2) -- C. Drazil and Factorial
- Codeforces Round #394(Div. 2)B. Dasha and friends【思维+暴力】
- Codeforces Round #395 (Div. 1) E. Timofey and our friends animals(lct动态维护mst)
- Codeforces Round #275 (Div. 2) --B Friends and Presents
- Codeforces Round #394 (Div. 2) B. Dasha and friends 暴力
- Codeforces Round #275 (Div. 2) B. Friends and Presents 二分+数学
- CF_292_B_Drazil and His Happy Friends_数学
- Codeforce 515 B . Drazil and His Happy Friends
- Codeforces Round #251 (Div. 2) D. Devu and his Brother
- codeforces Round 447 div2 D Ralph And His Tour in Binary Country
- Codeforces Round #305 (Div. 1)E. Mike and Friends 后缀数组+RMQ+线段树
- Codeforces Round #447 (Div. 2) D. Ralph And His Tour in Binary Country(dfs)