seerc 2014 D - Frame (傻逼题)
思路:注意xy-(x-2)*(y-2)=2x+2y-4,一定被2整除。因此siz为2的也是合法的。这个比较容易忘掉。
其他的判定条件都很好想。具体见代码;
1#include <cstdio>
2#include <cstring>
3#include <iostream>
4#include <algorithm>
5#include <vector>
6#include <queue>
7#include <set>
8#include <map>
9#include <string>
10#include <cmath>
11#include <cstdlib>
12#include <ctime>
13#define fst first
14#define sec second
15#define lson l,m,rt<<1
16#define rson m+1,r,rt<<1|1
17#define ms(a,x) memset(a,x,sizeof(a))
18typedef long long LL;
19#define pi pair < int ,int >
20#define MP make_pair
21using namespace std;
22const double eps = 1E-8;
23const int dx4[4]={1,0,0,-1};
24const int dy4[4]={0,-1,1,0};
25const int inf = 0x3f3f3f3f;
26int X,Y;
27bool ok( int a)
28{
29 if (a==2) return true;
30 if (X%a==0&&(Y-2)%a==0) return true;
31 if (Y%a==0&&(X-2)%a==0) return true;
32 if (X%a==1&&Y%a==1) return true;
1 return false;
2}
3int main()
4{
5 // freopen("in.txt","r",stdin);
1 while (~scanf("%d%d",&X,&Y))
2 {
3 int n;
4 scanf("%d",&n);
5 while (n--)
6 {
7 int x;
8 scanf("%d",&x);
9 // cout<<"x:"<<x<<endl;
10 if (ok(x)) puts("YES");
11 else puts("NO");
12 }
13 }
14return 0;
15}