結果

問題 No.827 総神童数
ユーザー hedwig100hedwig100
提出日時 2020-04-21 21:59:42
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
TLE  
実行時間 -
コード長 815 bytes
コンパイル時間 101 ms
コンパイル使用メモリ 10,872 KB
実行使用メモリ 50,704 KB
最終ジャッジ日時 2023-07-30 17:30:00
合計ジャッジ時間 37,160 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 20 ms
8,824 KB
testcase_01 AC 20 ms
8,656 KB
testcase_02 AC 20 ms
8,620 KB
testcase_03 AC 18 ms
8,760 KB
testcase_04 AC 21 ms
8,588 KB
testcase_05 AC 19 ms
8,736 KB
testcase_06 AC 19 ms
8,756 KB
testcase_07 AC 19 ms
8,656 KB
testcase_08 AC 19 ms
8,744 KB
testcase_09 TLE -
testcase_10 AC 588 ms
23,612 KB
testcase_11 AC 40 ms
9,484 KB
testcase_12 AC 247 ms
15,372 KB
testcase_13 AC 1,524 ms
42,488 KB
testcase_14 AC 63 ms
10,056 KB
testcase_15 AC 532 ms
22,432 KB
testcase_16 AC 1,546 ms
42,768 KB
testcase_17 AC 1,893 ms
48,876 KB
testcase_18 AC 704 ms
26,340 KB
testcase_19 TLE -
testcase_20 AC 1,378 ms
34,960 KB
testcase_21 AC 953 ms
27,940 KB
testcase_22 AC 1,540 ms
38,984 KB
testcase_23 AC 27 ms
8,844 KB
testcase_24 AC 1,733 ms
40,360 KB
testcase_25 AC 1,243 ms
32,976 KB
testcase_26 AC 1,756 ms
40,680 KB
testcase_27 AC 1,090 ms
30,084 KB
testcase_28 AC 1,063 ms
29,816 KB
testcase_29 AC 825 ms
25,540 KB
testcase_30 AC 222 ms
13,932 KB
testcase_31 AC 625 ms
21,992 KB
testcase_32 AC 596 ms
21,496 KB
testcase_33 AC 1,936 ms
43,684 KB
testcase_34 AC 1,835 ms
41,600 KB
testcase_35 AC 632 ms
22,076 KB
testcase_36 AC 939 ms
27,556 KB
testcase_37 AC 1,257 ms
32,960 KB
testcase_38 AC 1,915 ms
43,660 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

INF = 10 ** 9
MOD = 10 **9 + 7
import sys
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from  collections import deque
from math import factorial

def main():
    n = int(input())
    G = [[] for _ in range(n)]
    for _ in range(n - 1):
        a,b = map(int,input().split())
        a -= 1
        b -= 1
        G[a].append(b)
        G[b].append(a)
    
    stack = [(0,-1)]
    ancestors = [0] * n
    while stack:
        v,p = stack.pop()
        for e in G[v]:
            if e == p:
                continue
            ancestors[e] = ancestors[v] + 1
            stack.append((e,v))
    
    fact = factorial(n)%MOD
    
    ans = 0
    for d in ancestors:
        ans += fact * pow(d + 1,MOD - 2,MOD) % MOD
        ans %= MOD
    
    print(ans)
  
if __name__=='__main__':
    main()
0