-
Notifications
You must be signed in to change notification settings - Fork 0
/
ae2b.cpp
62 lines (62 loc) · 863 Bytes
/
ae2b.cpp
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
61
62
// 2009-12-21
#include <iostream>
using namespace std;
int gcd(int x,int y)
{
if (x==0) return y;
else return gcd(y%x,x);
}
int ABS(int x)
{
return x>0?x:-x;
}
char* ipos;
char infile[20000000];
int in()
{
int x=0;
int neg=0;
char c;
for(;;)
{
c=*ipos++;
if (c<=32)
return neg?-x:x;
if (c=='-')
neg=1;
else
x=(x<<1)+(x<<3)+c-'0';
}
return x;
}
int main()
{
ipos=infile;
fread_unlocked(infile,20000000,1,stdin);
int T;
T=in();
while (T--)
{
int K,N,x1,y1,x2,y2,dx,dy;
K=in(); N=in(); x1=in(); y1=in(); x2=in(); y2=in();
K=ABS(K);
N=ABS(N);
dx=ABS(x1-x2);
dy=ABS(y1-y2);
int f=gcd(K,N);
if (dx%f||dy%f)
printf("NIE\n");
else
{
K/=f; N/=f; dx/=f; dy/=f;
if (K%2 && N%2) //parity?
if (ABS(dx-dy)%2)
printf("NIE\n");
else
printf("TAK\n");
else
printf("TAK\n");
}
}
return 0;
}