-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj15988.java
More file actions
46 lines (36 loc) · 1.05 KB
/
boj15988.java
File metadata and controls
46 lines (36 loc) · 1.05 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.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class boj15988 {
static int N;
static long[] Dy;
static StringBuilder sb = new StringBuilder();
public static void main(String[] args) throws IOException {
preprocess();
pro();
}
static void preprocess() {
Dy = new long[1000001];
Dy[0] = 1;
for (int i = 1; i <= 1000000; i++) {
Dy[i] = Dy[i - 1];
if (i >= 2) {
Dy[i] += Dy[i - 2];
}
Dy[i] %= 1000000009;
if (i >= 3) {
Dy[i] += Dy[i - 3];
}
Dy[i] %= 1000000009;
}
}
static void pro() throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
N = Integer.parseInt(br.readLine());
while (N-- > 0){
int num = Integer.parseInt(br.readLine());
sb.append(Dy[num]).append('\n');
}
System.out.println(sb.toString());
}
}