데이터 엔지니어링 정복/Algorithm
[DP] 백준 - 이친수 (2193)
eeaarrtthh
2022. 7. 24. 02:49
728x90
반응형
-문제
https://www.acmicpc.net/problem/2193
-자바 풀이
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt( br.readLine() );
long[] dp = new long[91];
dp[1] = dp[2] = 1;
for( int i=3; i<=N; i++ ) dp[i] = dp[i-1] + dp[i-2];
System.out.println( dp[N] );
}
}
728x90
반응형