기본적인 DP문제였다.
#define DIV 1234567
#include <string>
#include <vector>
using namespace std;
long long solution(int n) {
long long answer = 0;
vector<int> DP(n + 1, 0);
DP[1] = 1;
DP[2] = 2;
for (int i = 3; i <= n; i++)
DP[i] = (DP[i - 1] + DP[i - 2]) % DIV;
answer = DP[n];
return answer;
}'Coding_Test 연습 > Programmers' 카테고리의 다른 글
| [프로그래머스] (C++) LV2 줄 서는 방법 (0) | 2022.06.10 |
|---|---|
| [프로그래머스] (C++) LV2 숫자 블록 (0) | 2022.06.10 |
| [프로그래머스] (C++) LV2 쿼드압축 후 개수 세기 (0) | 2022.06.08 |
| [프로그래머스] (C++) LV2 n^2 배열 자르기 (0) | 2022.06.05 |
| [프로그래머스] (C++) LV2 3 x n 타일링 (0) | 2022.06.04 |