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