-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMatches.java
52 lines (46 loc) · 1.07 KB
/
Matches.java
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
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main {
public static boolean func(long n , long m , boolean ans) {
//System.out.println(ans + " " + n + " " + m);
if (n==0 || m==0 || n==m || n%m == 0) {
return ans ;
}
else {
if (n/m >1 || m/n >1) {
return ans;
}
else {
if (n>m) {
n = n-m;
}
else if (m>n) {
m = m-n ;
}
ans = !ans;
return func(n,m,ans);
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine());
for (int p= 0; p< t ; p++) {
String[] inp = br.readLine().trim().split("\\s+");
long n = Long.parseLong(inp[0]);
long m = Long.parseLong(inp[1]);
boolean ans = true;
ans = func(n,m,ans);
if (ans == true) {
System.out.println("Ari");
}
if (ans==false) {
System.out.println("Rich");
}
}
}
catch (Exception E) {}
}
}