-
Notifications
You must be signed in to change notification settings - Fork 4
/
Main.java
31 lines (27 loc) · 922 Bytes
/
Main.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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
private static int[] one;
private static int[] zero;
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
int T = Integer.parseInt(br.readLine());
one = new int[41];
zero = new int[41];
one[0] = 0;
one[1] = 1;
zero[0] = 1;
zero[1] = 0;
for (int i = 2; i <= 40; i++) {
one[i] = one[i - 1] + one[i - 2];
zero[i] = zero[i - 1] + zero[i - 2];
}
for (int i = 0; i < T; i++) {
int num = Integer.parseInt(br.readLine());
sb.append(zero[num]).append(" ").append(one[num]).append("\n");
}
System.out.println(sb);
}
}