-
Notifications
You must be signed in to change notification settings - Fork 0
/
1.cpp
52 lines (46 loc) · 1 KB
/
1.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
#include <iostream>
#include <math.h>
using namespace std;
long maxDivit(long x, long y) {
long maxdivit = 1;
for (int i = 1; i <= y/2; i++) {
if (y%i == 0 && x%i == 0) {
maxdivit = i > maxdivit ? i : maxdivit;
}
}
return maxdivit;
}
int main() {
int T;
cin >> T;
while (T--) {
long x = 0;
long y = 0;
long c = 0;
long result = 0;
cin >> x >> y;
if (x < y) {
c = x;
x = y;
y = c;
}
if (x%y == 0) {
result = x/y;
if (result % 2 == 1) {
cout << "A" << endl;
} else {
cout << "B" << endl;
}
} else {
long maxdivit = 0;
maxdivit = maxDivit(x, y);
result = x/maxdivit;
if (result % 2 == 1) {
cout << "A" << endl;
} else {
cout << "B" << endl;
}
}
}
return 0;
}