結果
問題 | No.758 VVVVV |
ユーザー |
![]() |
提出日時 | 2020-03-19 00:57:34 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 157 ms / 2,000 ms |
コード長 | 609 bytes |
コンパイル時間 | 94 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 23,572 KB |
最終ジャッジ日時 | 2024-12-14 02:53:09 |
合計ジャッジ時間 | 3,206 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 23 |
ソースコード
#!/usr/bin/env python3.8import sysread = sys.stdin.buffer.readreadline = sys.stdin.buffer.readlinereadlines = sys.stdin.buffer.readlinesMOD = 10 ** 9 + 7N = int(readline())if N <= 2:print(1)exit()m = map(int, read().split())AB = zip(m, m)deg = [0] * (N + 1)for a, b in AB:deg[a] += 1deg[b] += 1leaf = sum(x == 1 for x in deg)fact = [1] * Nfor n in range(1, N):fact[n] = fact[n - 1] * n % MODnum = fact[N - 1] * fact[N - 2]den = fact[leaf - 1] * fact[N - leaf] * fact[leaf - 1] * fact[N - leaf - 1] * leafanswer = num * pow(den, MOD - 2, MOD) % MODprint(answer)