-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBAEKJOON_15990
More file actions
51 lines (41 loc) · 1.38 KB
/
BAEKJOON_15990
File metadata and controls
51 lines (41 loc) · 1.38 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
47
48
49
50
51
import java.io.*;
import java.sql.Array;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int test_case = Integer.parseInt(br.readLine());
int[][] d;
for(int t=1; t<=test_case; t++){
int N = Integer.parseInt(br.readLine());
d = new int[N+1][N+1];
for(int i=1; i<=N; i++){
if(i-1 >=0){
d[i][1] = d[i-1][2] + d[i-1][3];
if(i==1){
d[i][1]=1;
}
}
if(i-2>=0){
d[i][2] = d[i-2][1] + d[i-2][3];
if(i==2){
d[i][2]=1;
}
}
if(i-3>=0){
d[i][3] = d[i-3][1] + d[i-3][2];
if(i==3){
d[i][3] =1;
}
}
d[i][1] = d[i][1] % 1000000009;
d[i][2] = d[i][2] % 1000000009;
d[i][3] = d[i][3] % 1000000009;
}
bw.write(String.valueOf(d[N][1] + d[N][2] + d[N][3]));
bw.flush();
}
bw.close();
}
}