BOJ_S3_11727
π [S3_11727] 2*n νμΌλ§ 2
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());
int[] dp = new int[N+1];
dp[0] = 1;
dp[1] = 3;
for(int i=2; i<N; i++) {
dp[i] = (dp[i-1] + 2*dp[i-2]) % 10007;
}
System.out.println(dp[N-1]);
}
}
π€ λμ μκ°
λ¬Έμ λ₯Ό λ³΄κ³ κ³ λ―Όνλ€κ° λ¨Όμ λͺκ°λ₯Ό λμ΄ν΄λ³΄μλ€.
μλ λ°©λ²μ μ°Ύμ§ λͺ»ν λλ μ§μ ν΄λ³΄λκ² μ΅κ³ ..
n =1,2,3 κΉμ§ λμ΄ν΄λ³΄μλλ° κ·μΉμ μ°Ύμ μ μλ€.
dp[i] = dp[i-1] + 2*dp[i-2]
μ΄ κ³΅μμ νμ©ν΄μ λ¬Έμ μμ 10007λ‘ λλ λλ¨Έμ§κ°μ ꡬνλ©΄ λλ€.