Submission #18999

#TimeUsernameProblemLanguageResultExecution timeMemory
18999kriii악수 (kriii4_D)C++14
5 / 100
262 ms2888 KiB
#include <stdio.h> const long long mod = 1000000007; long long inv[450],comb[450][450],end[31][450],all[31][450]; 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<450;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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...