Created
September 18, 2018 13:52
-
-
Save developer-sdk/4dd80cde022c3039563b5bbd180b583b to your computer and use it in GitHub Desktop.
백준, 이친수, 2193, 다이나믹 프로그래밍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.Scanner; | |
| public class Problem2193 { | |
| public static long[][] dp; | |
| public static void main(String[] args) { | |
| Scanner sc = new Scanner(System.in); | |
| int N = sc.nextInt(); | |
| sc.close(); | |
| dp = new long[N + 1][2]; | |
| dp[1][0] = 0; | |
| dp[1][1] = 1; | |
| for (int i = 2; i <= N; i++) { | |
| dp[i][0] = dp[i - 1][0] + dp[i - 1][1]; | |
| dp[i][1] = dp[i - 1][0]; | |
| } | |
| System.out.println(dp[N][0] + dp[N][1]); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment