-
algospot - polyAlgorithm/알고스팟 2020. 2. 7. 14:41123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051//poly#include <iostream>#include <vector>using namespace std;#define MOD 10000000int N;vector<vector<int>> cache;void init(){cin >> N;cache = vector<vector<int>>(N + 1, vector<int>(N + 1, -1));}int dp(int n, int first){if (n == first)return 1;int &ret = cache[n][first];if (ret != -1)return ret;ret = 0;for (int i = 1; i <= n - first; ++i){ret += (first + i - 1) * dp(n - first, i);ret %= MOD;}return ret;}int main(){int C;cin >> C;for (int tn = 0; tn < C; ++tn){init();int ans = 0;for (int i = 1; i <= N; ++i){ans += dp(N, i);ans %= MOD;}cout << ans << "\n";}}
cs https://www.algospot.com/judge/problem/read/POLY
algospot.com :: POLY
폴리오미노 문제 정보 문제 정사각형들의 변들을 서로 완전하게 붙여 만든 도형들을 폴리오미노(Polyomino)라고 부릅니다. n개의 정사각형으로 구성된 폴리오미노들을 만들려고하는데, 이 중 세로로 단조(monotone)인 폴리오미노의 수가 몇 개나 되는지 세고 싶습니다. 세로로 단조라는 말은 어떤 가로줄도 폴리오미노를 두 번 이상 교차하지 않는다는 뜻입니다. 예를 들어 그림 (a)는 정상적인 세로 단조 폴리오미노입니다. 그러나 (b)는 점선이 폴리오미노를
www.algospot.com
poly
C(n, first) : 맨 윗줄이 first개인 n개의 폴리의 가짓수
C(n, first)는 각각의 C(n-first, i) (1 <= i <= n-first) 들과 조합할수 있는 가짓수의 합입니다!
각각의 C(n-first, i)와는 first + i - 1 가지의 조합을 만들어 낼수 있습니다!
<poly 점화식> 'Algorithm > 알고스팟' 카테고리의 다른 글
algospot - snail (0) 2020.02.08 algospot - numb3rs (0) 2020.02.07 algospot - asymtiling (0) 2020.02.03 algospot - tripathcnt (0) 2020.02.03 algospot - tiling2 (0) 2020.02.03