Problem/DP
[C/C++] BOJ 2193 :: 이친수
지무룩
2019. 1. 13. 22:18
BOJ 2193 :: 이친수
문제 링크 : https://www.acmicpc.net/problem/2193
다이나믹 프로그래밍으로 푸는 기본 문제이다.
풀이를 위한 그림 설명!
나의 코드
Github : https://github.com/j2wooooo/Daliy_Algorithms/blob/master/Daliy_Algorithms/BOJ_2193/BOJ_2193.cpp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | // 백준알고리즘 2193번 :: 이 #include<iostream> using namespace std; int N; long long dp[91]; int main() { cin >> N; dp[1] = 1; dp[2] = 1; for (int i = 3; i <= 90; i++) { dp[i] = dp[i - 2] + dp[i - 1]; } cout << dp[N]; return 0; } | cs |