-
-
Save fpdjsns/9551b310c588f495c9f9532867e79a56 to your computer and use it in GitHub Desktop.
[algospot][DP] 비대칭 타일링 : https://algospot.com/judge/problem/read/ASYMTILING
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <vector> | |
#include <set> | |
#include <algorithm> | |
#include <iostream> | |
/* | |
* 시간복잡도 : O(N) | |
*/ | |
using namespace std; | |
int MOD = 1000000007; | |
vector<int> dp; | |
int getAll(int n) { | |
if (n <= 1) return dp[n] = 1; | |
int& ret = dp[n]; | |
if (ret != -1) return ret; | |
ret = (getAll(n - 1) + getAll(n - 2)) % MOD; | |
return ret; | |
} | |
int getSymmetry(int n) { | |
int ans = dp[n / 2]; | |
if (n % 2 == 0) | |
ans = (ans + dp[n / 2 - 1]) % MOD; | |
return ans; | |
} | |
int main() { | |
int C; | |
cin >> C; | |
dp = vector<int>(101, -1); | |
while (C--) { | |
int N; | |
cin >> N; | |
int answer = (getAll(N) + MOD - getSymmetry(N)) % MOD; | |
cout << answer << endl; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment