結果

問題 No.827 総神童数
ユーザー rookzenorookzeno
提出日時 2019-05-24 20:56:22
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,802 ms / 2,000 ms
コード長 499 bytes
コンパイル時間 518 ms
コンパイル使用メモリ 11,784 KB
実行使用メモリ 85,864 KB
最終ジャッジ日時 2023-10-17 12:05:45
合計ジャッジ時間 31,841 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 28 ms
10,012 KB
testcase_01 AC 27 ms
10,012 KB
testcase_02 AC 28 ms
10,012 KB
testcase_03 AC 28 ms
10,012 KB
testcase_04 AC 27 ms
10,012 KB
testcase_05 AC 27 ms
10,012 KB
testcase_06 AC 27 ms
10,012 KB
testcase_07 AC 27 ms
10,012 KB
testcase_08 AC 28 ms
10,012 KB
testcase_09 AC 1,802 ms
85,864 KB
testcase_10 AC 595 ms
33,520 KB
testcase_11 AC 52 ms
11,156 KB
testcase_12 AC 265 ms
21,920 KB
testcase_13 AC 1,413 ms
72,844 KB
testcase_14 AC 79 ms
12,516 KB
testcase_15 AC 540 ms
34,920 KB
testcase_16 AC 1,425 ms
57,664 KB
testcase_17 AC 1,699 ms
69,240 KB
testcase_18 AC 705 ms
40,612 KB
testcase_19 AC 1,690 ms
45,968 KB
testcase_20 AC 1,203 ms
34,908 KB
testcase_21 AC 875 ms
28,220 KB
testcase_22 AC 1,337 ms
38,744 KB
testcase_23 AC 37 ms
10,216 KB
testcase_24 AC 1,485 ms
39,944 KB
testcase_25 AC 1,130 ms
32,892 KB
testcase_26 AC 1,471 ms
40,144 KB
testcase_27 AC 992 ms
30,196 KB
testcase_28 AC 963 ms
29,904 KB
testcase_29 AC 763 ms
26,048 KB
testcase_30 AC 245 ms
15,012 KB
testcase_31 AC 602 ms
22,540 KB
testcase_32 AC 610 ms
22,044 KB
testcase_33 AC 1,624 ms
43,116 KB
testcase_34 AC 1,486 ms
41,088 KB
testcase_35 AC 598 ms
22,680 KB
testcase_36 AC 852 ms
27,868 KB
testcase_37 AC 1,102 ms
32,844 KB
testcase_38 AC 1,602 ms
42,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
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
        dfs(i,y+1,x)
dfs(0,0,-1)
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