-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path11727.java
More file actions
27 lines (21 loc) · 713 Bytes
/
11727.java
File metadata and controls
27 lines (21 loc) · 713 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
br.close();
if(n == 1) {
System.out.println("1");
return;
}
int[] dp = new int[n + 1];
dp[1] = 1; dp[2] = 3;
System.out.println(solution(n, dp));
}
public static int solution(int n, int[] dp) {
if(dp[n] != 0) return dp[n];
return dp[n] = (solution(n - 1, dp) + solution(n - 2, dp) * 2) % 10007;
}
}