Last active
April 21, 2019 14:43
-
-
Save DonghoonPark12/03c945e5eb875aea6d75d5cb7e2e50f0 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 <iostream> | |
#include <vector> | |
using namespace std; | |
const int MOD = 10 * 1000 * 1000; | |
long long poly(vector<vector<long long>> D, int N) { | |
for (int n = 1; n <= N; n++) { | |
for (int down = 1; down <= n; down++) { | |
for (int i = 1; i <= n - down; i++) { | |
D[n][down] += D[n - down][i] * (down + i - 1); | |
} | |
if (n == down) | |
D[n][down] = 1; | |
D[n][down] %= MOD; | |
} | |
} | |
long long ans = 0; | |
for (int down = 1; down<= N; down++) { | |
ans += D[N][down]; | |
ans %= MOD; | |
} | |
return ans ; | |
} | |
int main() { | |
freopen("input.txt", "r", stdin); | |
int T; | |
cin >> T; | |
for (int t = 0; t < T; t++) { | |
int n; cin >> n; | |
vector<vector<long long>> D(101, vector<long long>(101)); | |
cout << poly(D, n) << endl;; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
다른 풀이
https://sangdo913.tistory.com/41