# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
19264 |
2016-02-23T14:05:41 Z |
kriii |
악수 (kriii4_D) |
C++14 |
|
1238 ms |
6600 KB |
#include <stdio.h>
const long long mod = 1000000007;
long long inv[800],comb[800][800],end[41][800],all[41][800];
int main()
{
int n,m; scanf ("%d",&n);
comb[0][0] = comb[1][0] = comb[1][1] = inv[1] = 1;
for (int i=2;i<800;i++){
comb[i][0] = comb[i][i] = 1;
for (int j=1;j<i;j++) comb[i][j] = (comb[i-1][j-1] + comb[i-1][j]) % mod;
inv[i] = (mod - mod / i) * inv[mod % i] % mod;
}
end[1][0] = all[1][0] = 1;
for (int v=2;v<=n;v++){
int l = v * (v - 1) / 2;
for (int e=v-1;e<=l;e++){
for (int i=0;i<v-1;i++) for (int j=0;j<e;j++){
long long add = comb[v-1][i] * comb[e-1][j] % mod;
add = add * all[i+1][j] % mod;
add = add * all[v-i-1][e-j-1] % mod;
add = add * (i + 1) * (v - i - 1) % mod;
end[v][e] += add;
}
end[v][e] %= mod;
all[v][e] = (end[v][e] + (l - e + 1) * all[v][e-1]) % mod;
}
}
long long coeff = 1, ans = 0;
m = n * (n - 1) / 2;
for (int i=1;i<=m;i++){
coeff = coeff * inv[m-i+1] % mod;
ans = (ans + end[n][i] * coeff % mod * i) % mod;
}
printf ("%lld\n",ans);
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
6600 KB |
Output is correct |
2 |
Correct |
0 ms |
6600 KB |
Output is correct |
3 |
Correct |
2 ms |
6600 KB |
Output is correct |
4 |
Correct |
0 ms |
6600 KB |
Output is correct |
5 |
Correct |
2 ms |
6600 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
6600 KB |
Output is correct |
2 |
Correct |
0 ms |
6600 KB |
Output is correct |
3 |
Correct |
2 ms |
6600 KB |
Output is correct |
4 |
Correct |
0 ms |
6600 KB |
Output is correct |
5 |
Correct |
0 ms |
6600 KB |
Output is correct |
6 |
Correct |
0 ms |
6600 KB |
Output is correct |
7 |
Correct |
3 ms |
6600 KB |
Output is correct |
8 |
Correct |
3 ms |
6600 KB |
Output is correct |
9 |
Correct |
4 ms |
6600 KB |
Output is correct |
10 |
Correct |
5 ms |
6600 KB |
Output is correct |
11 |
Correct |
7 ms |
6600 KB |
Output is correct |
12 |
Correct |
6 ms |
6600 KB |
Output is correct |
13 |
Correct |
12 ms |
6600 KB |
Output is correct |
14 |
Correct |
16 ms |
6600 KB |
Output is correct |
15 |
Correct |
17 ms |
6600 KB |
Output is correct |
16 |
Correct |
27 ms |
6600 KB |
Output is correct |
17 |
Correct |
36 ms |
6600 KB |
Output is correct |
18 |
Correct |
46 ms |
6600 KB |
Output is correct |
19 |
Correct |
59 ms |
6600 KB |
Output is correct |
20 |
Correct |
75 ms |
6600 KB |
Output is correct |
21 |
Correct |
94 ms |
6600 KB |
Output is correct |
22 |
Correct |
117 ms |
6600 KB |
Output is correct |
23 |
Correct |
143 ms |
6600 KB |
Output is correct |
24 |
Correct |
180 ms |
6600 KB |
Output is correct |
25 |
Correct |
221 ms |
6600 KB |
Output is correct |
26 |
Correct |
268 ms |
6600 KB |
Output is correct |
27 |
Correct |
325 ms |
6600 KB |
Output is correct |
28 |
Correct |
386 ms |
6600 KB |
Output is correct |
29 |
Correct |
466 ms |
6600 KB |
Output is correct |
30 |
Correct |
552 ms |
6600 KB |
Output is correct |
31 |
Correct |
655 ms |
6600 KB |
Output is correct |
32 |
Correct |
772 ms |
6600 KB |
Output is correct |
33 |
Correct |
914 ms |
6600 KB |
Output is correct |
34 |
Correct |
1058 ms |
6600 KB |
Output is correct |
35 |
Correct |
1238 ms |
6600 KB |
Output is correct |