-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathboj10826.java
More file actions
41 lines (33 loc) · 1007 Bytes
/
boj10826.java
File metadata and controls
41 lines (33 loc) · 1007 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
41
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class boj10826 {
static int n;
static BigInteger[] arr;
static StringBuilder sb = new StringBuilder();
public static void main(String[] args) throws IOException {
input();
pro();
}
static void input() throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
n = Integer.parseInt(br.readLine());
arr = new BigInteger[n + 1];
}
static void pro() {
if (n == 0) {
sb.append('0');
} else if (n == 1) {
sb.append('1');
} else {
arr[0] = BigInteger.valueOf(0);
arr[1] = BigInteger.valueOf(1);
for (int i = 2; i <= n; i++) {
arr[i] = arr[i - 1].add(arr[i - 2]);
}
sb.append(arr[n]);
}
System.out.println(sb.toString());
}
}