Submission #957722

#TimeUsernameProblemLanguageResultExecution timeMemory
957722Erfan1386YZapina (COCI20_zapina)C++14
110 / 110
200 ms3420 KiB
#include <bits/stdc++.h> #define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout); #define fast_io ios::sync_with_stdio(false);cin.tie(0); #define what(x) cerr << #x << " is " << x << '\n'; #define kill(x) {cout << x << '\n'; return;} #define all(x) (x).begin(), (x).end() #define pii pair<int, int> #define pb push_back #define ll long long #define F first #define S second const ll inf = 1e16, mod = 1e9 + 7, delta = 1e9 + 9, SQ = 350, P = 6065621; using namespace std; const int N = 360, LG = 21; ll fac[N], inv[N], pw[N][N]; ll dp[N][N], pd[N][N]; ll poww (ll a, ll b) { if (!b) return 1; if (b & 1) return a * poww(a * a % mod, b / 2) % mod; return poww(a * a % mod, b / 2); } ll C(int n, int r) { if (r > n || r < 0) return 0; if (r == n || r == 0) return 1; return fac[n] * inv[r] % mod * inv[n - r] % mod; } int main () { fast_io; fac[0] = 1; for (int i = 1; i < N; i++) { fac[i] = fac[i - 1] * i % mod; inv[i] = poww(fac[i], mod - 2); } pw[0][0] = 1; for (int i = 1; i < N; i++) { pw[i][0] = 1; for (int j = 1; j < N; j++) { pw[i][j] = pw[i][j - 1] * i % mod; } } int n; cin >> n; for (int i = 1; i <= n; i++) { for (int j = 1; j <= n; j++) { for (int k = 0; k <= j; k++) { if (k == i) { dp[i][j] += C(j, k) * (pw[i - 1][j - k]) % mod; dp[i][j] %= mod; } else { dp[i][j] += C(j, k) * dp[i - 1][j - k] % mod; dp[i][j] %= mod; } } } } cout << dp[n][n] << '\n'; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...