문제

소스코드
#include <bits/stdc++.h>
using namespace std;
int dp[1000001];
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int n;
cin >> n;
dp[1] = 1, dp[2] = 2;
for (int i = 3; i <= n; i++) {
dp[i] = (dp[i - 1] + dp[i - 2]) % 15746;
}
cout << dp[n];
}
풀이
규칙을 찾아보면 쉽게 해결 할 수 있다.
이건 타일문제의 기초 단계인거 같다.
'Algorithm > dynamic programming' 카테고리의 다른 글
| [백준] 알고리즘 10844번 - 쉬운 계단 수 문제 (0) | 2021.03.17 |
|---|---|
| [백준] 알고리즘 1932번 - 정수 삼각형 문제 (0) | 2021.03.14 |
| [백준] 알고리즘 1149번 - RGB거리 문제 (0) | 2021.03.11 |
| [백준] 알고리즘 9184번 - 신나는 함수 실행 문제 (0) | 2021.03.10 |
| [백준] 알고리즘 1003번 - 피보나치 함수 문제 (0) | 2021.03.09 |
