【HAOI2011】向量

Source and Judge

HAOI2011
bzoj2299

Analysis

请先思考后再展开

裴蜀定理的应用
最难的一步是转化为,+-2a,+-2b,(+a,+b),(+b,+a)
然后后面两个只会进行最多一次,暴力枚举判断

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
typedef long long ll;
const int INF=0x3f3f3f3f;
ll qread()
{
ll ans=0;char c=getchar();int f=1;
while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
return ans*f;
}
void write(int num)
{
if(num<0) {num=-num;putchar('-');}
if(num>9) write(num/10);
putchar('0'+num%10);
}
void writeln(int num){write(num);puts("");}
#define pr pair<int,int>
#define FR first
#define SE second
#define MP make_pair
inline void chmin(ll &x,ll y) {x=x<y?x:y;}
ll gcd(ll x,ll y) {return y==0?x:gcd(y,x%y);}
ll a,b;bool solve(ll x,ll y) {return x%gcd(2*a,2*b)==0 and y%gcd(2*a,2*b)==0;}
void main()
{
int T;scanf("%d",&T);
while(T--)
{
ll x,y;a=qread();b=qread();x=qread();y=qread();
if(solve(x+a,y+b) or solve(x+b,y+a) or solve(x,y) or solve(x+a+b,y+a+b)) puts("Y");
else puts("N");
}
}
};
int main()
{
srand(time(0));
mine::main();
}

本文基于 知识共享署名-相同方式共享 4.0 国际许可协议发布
本文地址:http://zory.ink/posts/a027.html
转载请注明出处,谢谢!