728x90
▶11727번 문제
▶풀이방법
import java.io.*;
public class Main{
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
int num = Integer.parseInt(br.readLine());
int[] dp = new int[num+2];
dp[1] = 1;
dp[2] = 3;
for(int i = 3; i <= num; i++) {
dp[i] = (dp[i-1] + 2*dp[i-2]) % 10007;
}
bw.write(String.valueOf(dp[num]));
bw.flush();
bw.close();
br.close();
}
}
728x90
'Algorithm > BaekJoon[Java]' 카테고리의 다른 글
백준 10844 (0) | 2022.03.21 |
---|---|
백준 9095 (0) | 2022.03.20 |
백준 11726 (0) | 2022.03.19 |
백준 1463(Dynamic Programming) (0) | 2022.03.19 |
백준 10991, 10992 (별찍기) (0) | 2022.03.18 |