-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathd.java
More file actions
46 lines (45 loc) · 1.17 KB
/
d.java
File metadata and controls
46 lines (45 loc) · 1.17 KB
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
import java.io.*;
import java.util.*;
public class d{
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw = new PrintWriter(System.out);
static StringTokenizer st = new StringTokenizer("");
static int fib[];
static boolean solve(int w, int h, int x, int y, int f){
//pw.println(w + " " + h + " " + x + " " + y + " " + f);
if(f == 1) return true;
if(x <= fib[f-1]){
return solve(h, w-fib[f], y, x, f-1);
}else if(x > fib[f]){
return solve(h, w-fib[f], y, x-fib[f], f-1);
}else{
return false;
}
}
public static void main(String[] args) throws IOException{
int T = nextInt();
fib = new int[50];
fib[0] = 1; fib[1] = 1;
for(int i = 2; i < 50; i++){
fib[i] = fib[i-1] + fib[i-2];
}
while(T --> 0){
int N = nextInt(), X = nextInt(), Y = nextInt();
if(solve(fib[N+1], fib[N], Y, X, N)){
pw.println("yES");
}else{
pw.println("nO");
}
}
br.close(); pw.close();
}
static String next() throws IOException{
while(!st.hasMoreTokens()){
st = new StringTokenizer(br.readLine());
}
return st.nextToken();
}
static int nextInt() throws IOException{
return Integer.parseInt(next());
}
}