1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include <iostream>
#include <vector>
#define MOD 15746
using namespace std;
vector<int> dp(1000001, -1);
int findAnswer(int n) {
if (n <= 2) {
return n;
}
int& ret = dp[n];
if (ret != -1) return ret;
int a = findAnswer(n - 2);
int b = findAnswer(n - 1);
return ret = (a + b) % MOD;
}
int main() {
int n;
dp[1] = 1;
dp[2] = 2;
cin >> n;
cout << findAnswer(n) << endl;;
return 0;
}
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
'Baekjoon' 카테고리의 다른 글
[#1931] 회의실 배정 (0) | 2020.03.13 |
---|---|
[#11047] 동전 0 (0) | 2020.03.13 |
[#2193] 이친수 (0) | 2020.03.12 |
[#12865] 평범한 배낭 (0) | 2020.03.12 |
[#1912] 연속합 (0) | 2020.03.12 |