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;
33
34    return false;
35}
36int main()
37{
38 // freopen("in.txt","r",stdin);
39
40  while (~scanf("%d%d",&X,&Y))
41  {
42      int n;
43      scanf("%d",&n);
44      while (n--)
45      {
46          int x;
47          scanf("%d",&x);
48         // cout<<"x:"<<x<<endl;
49          if (ok(x)) puts("YES");
50          else puts("NO");
51      }
52  }
53return 0;
54}