Skip to content

Instantly share code, notes, and snippets.

@developer-sdk
Created September 18, 2018 13:52
Show Gist options
  • Select an option

  • Save developer-sdk/4dd80cde022c3039563b5bbd180b583b to your computer and use it in GitHub Desktop.

Select an option

Save developer-sdk/4dd80cde022c3039563b5bbd180b583b to your computer and use it in GitHub Desktop.
백준, 이친수, 2193, 다이나믹 프로그래밍
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