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