-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBOJ2193.java
More file actions
37 lines (29 loc) · 883 Bytes
/
BOJ2193.java
File metadata and controls
37 lines (29 loc) · 883 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class BOJ2193 {
static int n;
static long[][] dp;
private static void input() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(br.readLine());
dp = new long[n + 1][2];
}
public static void main(String[] args) throws IOException {
input();
process();
}
private static void process() {
// set init
dp[1][0] = 0;
dp[1][1] = 1;
// set others
for (int i = 2; i <= n; i++) {
dp[i][0] = dp[i-1][0] + dp[i-1][1];
dp[i][1] = dp[i-1][0];
}
// print answer
System.out.println(dp[n][0] + dp[n][1]);
}
}