結果

問題 No.827 総神童数
ユーザー rookzenorookzeno
提出日時 2019-05-24 21:01:31
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 621 ms / 2,000 ms
コード長 603 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 81,692 KB
実行使用メモリ 101,600 KB
最終ジャッジ日時 2023-10-17 12:07:39
合計ジャッジ時間 13,383 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,312 KB
testcase_01 AC 42 ms
55,312 KB
testcase_02 AC 43 ms
55,312 KB
testcase_03 AC 42 ms
55,312 KB
testcase_04 AC 42 ms
55,312 KB
testcase_05 AC 42 ms
55,312 KB
testcase_06 AC 41 ms
55,312 KB
testcase_07 AC 42 ms
55,312 KB
testcase_08 AC 43 ms
55,312 KB
testcase_09 AC 496 ms
99,520 KB
testcase_10 AC 226 ms
84,732 KB
testcase_11 AC 90 ms
76,480 KB
testcase_12 AC 146 ms
80,076 KB
testcase_13 AC 402 ms
94,760 KB
testcase_14 AC 99 ms
77,024 KB
testcase_15 AC 208 ms
83,792 KB
testcase_16 AC 422 ms
96,532 KB
testcase_17 AC 480 ms
99,720 KB
testcase_18 AC 248 ms
86,152 KB
testcase_19 AC 621 ms
101,600 KB
testcase_20 AC 461 ms
94,832 KB
testcase_21 AC 354 ms
89,788 KB
testcase_22 AC 504 ms
96,292 KB
testcase_23 AC 88 ms
76,956 KB
testcase_24 AC 547 ms
98,920 KB
testcase_25 AC 432 ms
93,444 KB
testcase_26 AC 562 ms
98,984 KB
testcase_27 AC 389 ms
91,720 KB
testcase_28 AC 382 ms
90,916 KB
testcase_29 AC 327 ms
88,284 KB
testcase_30 AC 157 ms
80,108 KB
testcase_31 AC 271 ms
85,696 KB
testcase_32 AC 267 ms
85,072 KB
testcase_33 AC 600 ms
100,744 KB
testcase_34 AC 548 ms
98,600 KB
testcase_35 AC 269 ms
85,660 KB
testcase_36 AC 360 ms
89,604 KB
testcase_37 AC 438 ms
93,404 KB
testcase_38 AC 586 ms
100,556 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque
sys.setrecursionlimit(20000000)
#input = sys.stdin.readline
n = int(input())
g = [[] for i in range(n)]
for i in range(n-1):
    u,v = map(int,input().split())
    u-=1;v-=1
    g[u].append(v)
    g[v].append(u)
hu = [0]*n
def dfs(x,y,z):
    hu[x] =y
    for i in g[x]:
        if i == z:
            continue
        q.append([i,y+1,x])
q = deque()
q.append([0,0,-1])
while q:
    x,y,z = q.popleft()
    dfs(x,y,z)
bi = 1
mod = 10**9+7
for i in range(1,n+1):
    bi*=i
    bi%=mod
ans = 0
for i in hu:
    ans+= bi*pow(i+1,mod-2,mod)
    ans %= mod
print(ans)
0