-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBAEKJOON_1309
More file actions
41 lines (28 loc) · 934 Bytes
/
BAEKJOON_1309
File metadata and controls
41 lines (28 loc) · 934 Bytes
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
import java.io.*;
import java.sql.Array;
import java.util.*;
import java.util.stream.Stream;
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 N = Integer.parseInt(br.readLine());
long[][] d = new long[N+1][3];
d[1][0]=1;
d[1][1]=1;
d[1][2]=1;
for(int i=2; i<=N; i++){
d[i][0] = d[i-1][0]+d[i-1][1]+d[i-1][2];
d[i][1] = d[i-1][0] + d[i-1][2];
d[i][2] = d[i-1][0] + d[i-1][1];
for(int j=0; j<3; j++){
d[i][j]%=9901;
}
}
long sum = d[N][0]+d[N][1]+d[N][2];
long result = sum%9901;
bw.write(String.valueOf(result));
bw.flush();
bw.close();
}
}