-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ1793.java
More file actions
27 lines (22 loc) · 780 Bytes
/
BOJ1793.java
File metadata and controls
27 lines (22 loc) · 780 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
package quki.algorithm.dp;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
public class BOJ1793 {
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
while(true){
String line = br.readLine();
if(line==null) break;
int n = Integer.parseInt(line);
BigInteger d[] = new BigInteger[251];
d[0] = BigInteger.ONE;
d[1] = BigInteger.ONE;
for(int i = 2; i<= n;i++){
d[i] = d[i-1].add(d[i-2].multiply(new BigInteger("2")));
}
System.out.println(d[n]);
}
}
}