-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ11727.java
More file actions
30 lines (26 loc) Β· 935 Bytes
/
Q11727.java
File metadata and controls
30 lines (26 loc) Β· 935 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
/**
* Date: 2018. 08. 09.
* Author: inhyuck | https://github.com/inhyuck
* Solution URL: https://github.com/skhucode/skhucode-inhyuck
* Title: 2 x n νμΌλ§ 2
* Problem: 2Γn ν¬κΈ°μ μ§μ¬κ°νμ 1Γ2, 2Γ1, 2x2 νμΌλ‘ μ±μ°λ
* λ°©λ²μ μλ₯Ό ꡬνλ νλ‘κ·Έλ¨μ μμ±νμμ€.
* URL: https://www.acmicpc.net/problem/11727
*/
package io.inhyuck.dp;
import java.util.*;
public class Q11727 {
public static int[] dp;
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
// dp[n] | 2 x n ν¬κΈ°μ μ§μ¬κ°νμ μ±μ°λ λ°©λ²μ μ
dp = new int[n + 1];
dp[0] = 1; // dp[n] = dp[n-1] + dp[n-2] * 2 λ₯Ό μν λͺ
μμ 쑰건
dp[1] = 1;
for (int i = 2; i <= n; i++) {
dp[i] = (dp[i - 1] + dp[i - 2] * 2) % 10007;
}
System.out.println(dp[n]);
}
}