結果

問題 No.827 総神童数
ユーザー kurimupykurimupy
提出日時 2020-06-15 15:03:30
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
RE  
実行時間 -
コード長 642 bytes
コンパイル時間 94 ms
コンパイル使用メモリ 10,984 KB
実行使用メモリ 45,824 KB
最終ジャッジ日時 2023-09-16 10:20:46
合計ジャッジ時間 27,835 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,864 KB
testcase_01 AC 16 ms
7,780 KB
testcase_02 AC 16 ms
7,820 KB
testcase_03 AC 16 ms
7,820 KB
testcase_04 AC 16 ms
7,784 KB
testcase_05 AC 16 ms
7,896 KB
testcase_06 AC 16 ms
7,760 KB
testcase_07 AC 16 ms
7,812 KB
testcase_08 AC 16 ms
7,856 KB
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 1,800 ms
45,824 KB
testcase_20 AC 1,279 ms
34,340 KB
testcase_21 AC 927 ms
27,320 KB
testcase_22 AC 1,406 ms
38,320 KB
testcase_23 AC 25 ms
8,472 KB
testcase_24 AC 1,548 ms
39,456 KB
testcase_25 AC 1,181 ms
32,080 KB
testcase_26 AC 1,560 ms
39,712 KB
testcase_27 AC 1,035 ms
29,280 KB
testcase_28 AC 1,013 ms
29,012 KB
testcase_29 AC 810 ms
25,036 KB
testcase_30 AC 246 ms
13,476 KB
testcase_31 AC 627 ms
21,236 KB
testcase_32 AC 602 ms
20,780 KB
testcase_33 AC 1,725 ms
42,748 KB
testcase_34 AC 1,564 ms
40,612 KB
testcase_35 AC 626 ms
21,392 KB
testcase_36 AC 912 ms
26,936 KB
testcase_37 AC 1,195 ms
32,036 KB
testcase_38 AC 1,718 ms
42,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
graph = [[] for i in range(N+1)]
for i in range(N-1):
    u, v = map(int, input().split())
    graph[u].append(v)
    graph[v].append(u)
visited = [False for i in range(N+1)]
distance = [1 for i in range(N+1)]
def dfs(S):
    visited[S] = True
    for node in graph[S]:
        if visited[node] == False:
            visited[node] = True
            distance[node] = distance[S]+1
            dfs(node)
dfs(1) 
mod=10**9+7
power=1
for i in range(1,N+1):
    power*=i
    power%=mod
def rev(X,mod):
    return pow(X,mod-2,mod)
ans=0
for i in range(1,N+1):
    ans+=power*rev(distance[i],mod)%mod
print(ans%mod)

            

0