# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
957646 |
2024-04-04T06:59:53 Z |
vjudge1 |
Zapina (COCI20_zapina) |
C++17 |
|
195 ms |
3324 KB |
#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;
// dp[0][0] = 1;
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;
}
}
}
}
// what(dp[1][2]);
cout << dp[n][n] << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
2 ms |
3164 KB |
Output is correct |
4 |
Correct |
1 ms |
3160 KB |
Output is correct |
5 |
Correct |
1 ms |
3164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
2 ms |
3164 KB |
Output is correct |
4 |
Correct |
1 ms |
3160 KB |
Output is correct |
5 |
Correct |
1 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
1 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
2 ms |
3164 KB |
Output is correct |
10 |
Correct |
1 ms |
3160 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
1 ms |
3164 KB |
Output is correct |
15 |
Correct |
2 ms |
3164 KB |
Output is correct |
16 |
Correct |
2 ms |
3164 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
3164 KB |
Output is correct |
2 |
Correct |
1 ms |
3164 KB |
Output is correct |
3 |
Correct |
2 ms |
3164 KB |
Output is correct |
4 |
Correct |
1 ms |
3160 KB |
Output is correct |
5 |
Correct |
1 ms |
3164 KB |
Output is correct |
6 |
Correct |
1 ms |
3164 KB |
Output is correct |
7 |
Correct |
1 ms |
3164 KB |
Output is correct |
8 |
Correct |
1 ms |
3164 KB |
Output is correct |
9 |
Correct |
2 ms |
3164 KB |
Output is correct |
10 |
Correct |
1 ms |
3160 KB |
Output is correct |
11 |
Correct |
1 ms |
3164 KB |
Output is correct |
12 |
Correct |
1 ms |
3164 KB |
Output is correct |
13 |
Correct |
1 ms |
3164 KB |
Output is correct |
14 |
Correct |
1 ms |
3164 KB |
Output is correct |
15 |
Correct |
2 ms |
3164 KB |
Output is correct |
16 |
Correct |
2 ms |
3164 KB |
Output is correct |
17 |
Correct |
83 ms |
3316 KB |
Output is correct |
18 |
Correct |
2 ms |
3160 KB |
Output is correct |
19 |
Correct |
20 ms |
3324 KB |
Output is correct |
20 |
Correct |
1 ms |
3164 KB |
Output is correct |
21 |
Correct |
109 ms |
3164 KB |
Output is correct |
22 |
Correct |
13 ms |
3160 KB |
Output is correct |
23 |
Correct |
3 ms |
3164 KB |
Output is correct |
24 |
Correct |
24 ms |
3164 KB |
Output is correct |
25 |
Correct |
16 ms |
3164 KB |
Output is correct |
26 |
Correct |
34 ms |
3312 KB |
Output is correct |
27 |
Correct |
154 ms |
3164 KB |
Output is correct |
28 |
Correct |
154 ms |
3296 KB |
Output is correct |
29 |
Correct |
153 ms |
3296 KB |
Output is correct |
30 |
Correct |
172 ms |
3300 KB |
Output is correct |
31 |
Correct |
159 ms |
3300 KB |
Output is correct |
32 |
Correct |
157 ms |
3164 KB |
Output is correct |
33 |
Correct |
195 ms |
3160 KB |
Output is correct |
34 |
Correct |
159 ms |
3160 KB |
Output is correct |
35 |
Correct |
160 ms |
3160 KB |
Output is correct |
36 |
Correct |
167 ms |
3300 KB |
Output is correct |
37 |
Correct |
167 ms |
3300 KB |
Output is correct |