#include <iostream>
using namespace std;
int N;
int dp[100001][3];
int result;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> N;
dp[1][0] = 1;
dp[1][1] = 1;
dp[1][2] = 1;
for (int i = 2; i <= N ; i++)
{
dp[i][0] = (dp[i - 1][0] + dp[i - 1][1] + dp[i - 1][2]) % 9901;
dp[i][1] = (dp[i - 1][0] + dp[i - 1][2]) % 9901;
dp[i][2] = (dp[i - 1][0] + dp[i - 1][1]) % 9901;
}
result = (dp[N][0] + dp[N][1] + dp[N][2]) % 9901;
cout << result << "\n";
return 0;
}
DP 관련 문제였다.
Baekjoon_Link 👈 Click here