import java.util.Scanner;
public class P2748 { // 오버플로우, n = 0,1,2 일 때 예외처리
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println(fibonacci(sc.nextInt()));
sc.close();
}
private static long fibonacci(int n) {
if(n == 0) return 0;
if(n == 1 || n == 2) return 1;
long[] dp = new long[n + 1];
dp[1] = dp[2] = 1;
for (int i = 3; i <= n; i++) {
dp[i] = dp[i - 1] + dp[i - 2];
}
return dp[n];
}
}
© 2021 GitHub, Inc.