結果

問題 No.196 典型DP (1)
ユーザー rpy3cpprpy3cpp
提出日時 2015-09-09 18:23:23
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 210 ms / 2,000 ms
コード長 509 bytes
コンパイル時間 1,252 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 101,360 KB
最終ジャッジ日時 2023-08-25 02:17:49
合計ジャッジ時間 9,107 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 67 ms
71,108 KB
testcase_01 AC 68 ms
71,448 KB
testcase_02 AC 71 ms
71,324 KB
testcase_03 AC 69 ms
71,536 KB
testcase_04 AC 69 ms
71,604 KB
testcase_05 AC 69 ms
71,348 KB
testcase_06 AC 69 ms
71,412 KB
testcase_07 AC 68 ms
71,348 KB
testcase_08 AC 68 ms
71,504 KB
testcase_09 AC 68 ms
71,228 KB
testcase_10 AC 67 ms
71,444 KB
testcase_11 AC 66 ms
71,280 KB
testcase_12 AC 71 ms
75,628 KB
testcase_13 AC 75 ms
75,744 KB
testcase_14 AC 76 ms
76,360 KB
testcase_15 AC 85 ms
76,512 KB
testcase_16 AC 100 ms
77,056 KB
testcase_17 AC 122 ms
77,972 KB
testcase_18 AC 144 ms
78,436 KB
testcase_19 AC 151 ms
78,824 KB
testcase_20 AC 184 ms
79,280 KB
testcase_21 AC 200 ms
79,424 KB
testcase_22 AC 196 ms
80,200 KB
testcase_23 AC 208 ms
101,360 KB
testcase_24 AC 181 ms
82,944 KB
testcase_25 AC 210 ms
98,012 KB
testcase_26 AC 176 ms
94,332 KB
testcase_27 AC 173 ms
94,020 KB
testcase_28 AC 171 ms
94,396 KB
testcase_29 AC 166 ms
94,368 KB
testcase_30 AC 173 ms
93,896 KB
testcase_31 AC 189 ms
78,040 KB
testcase_32 AC 188 ms
78,024 KB
testcase_33 AC 189 ms
78,040 KB
testcase_34 AC 197 ms
77,988 KB
testcase_35 AC 192 ms
78,060 KB
testcase_36 AC 190 ms
78,036 KB
testcase_37 AC 170 ms
78,408 KB
testcase_38 AC 190 ms
78,460 KB
testcase_39 AC 182 ms
78,184 KB
testcase_40 AC 194 ms
78,092 KB
testcase_41 AC 68 ms
71,580 KB
testcase_42 AC 67 ms
71,188 KB
testcase_43 AC 67 ms
71,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(4000)
def f(v,p,E):
  if v and len(E[v])==1: return [1,1]
  L=[1]
  for c in E[v]:
    if c==p: continue
    L=m(L,f(c,v,E))
  L.append(1)
  return L
def m(L1, L2):
  M=10**9+7
  L=[0]*(len(L1)+len(L2)-1)
  for i,a in enumerate(L1):
    for j,b in enumerate(L2): L[i+j]+=a*b
  return [v%M for v in L]
N,K=map(int,input().split())
E=[[] for i in range(N)]
for i in range(N-1):
  a,b=map(int,input().split())
  E[a].append(b)
  E[b].append(a)
L=f(0,-1,E)
L.append(1)
print(L[K])
0