結果

問題 No.916 Encounter On A Tree
ユーザー kurimupykurimupy
提出日時 2020-06-18 14:26:05
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,135 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 10,964 KB
実行使用メモリ 58,468 KB
最終ジャッジ日時 2023-09-16 12:06:56
合計ジャッジ時間 35,493 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 520 ms
58,420 KB
testcase_01 AC 532 ms
58,380 KB
testcase_02 AC 528 ms
58,432 KB
testcase_03 WA -
testcase_04 AC 519 ms
58,428 KB
testcase_05 WA -
testcase_06 AC 513 ms
58,324 KB
testcase_07 WA -
testcase_08 AC 530 ms
58,344 KB
testcase_09 AC 513 ms
58,304 KB
testcase_10 AC 513 ms
58,248 KB
testcase_11 AC 520 ms
58,256 KB
testcase_12 AC 518 ms
58,300 KB
testcase_13 AC 517 ms
58,280 KB
testcase_14 AC 536 ms
58,400 KB
testcase_15 AC 528 ms
58,284 KB
testcase_16 AC 518 ms
58,232 KB
testcase_17 AC 518 ms
58,444 KB
testcase_18 AC 514 ms
58,316 KB
testcase_19 AC 521 ms
58,412 KB
testcase_20 AC 516 ms
58,328 KB
testcase_21 WA -
testcase_22 AC 523 ms
58,228 KB
testcase_23 WA -
testcase_24 AC 534 ms
58,256 KB
testcase_25 WA -
testcase_26 AC 531 ms
58,392 KB
testcase_27 WA -
testcase_28 AC 519 ms
58,428 KB
testcase_29 WA -
testcase_30 AC 524 ms
58,300 KB
testcase_31 AC 517 ms
58,252 KB
testcase_32 AC 537 ms
58,280 KB
testcase_33 AC 524 ms
58,256 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 523 ms
58,388 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 534 ms
58,344 KB
testcase_40 AC 522 ms
58,320 KB
testcase_41 AC 543 ms
58,320 KB
testcase_42 AC 525 ms
58,252 KB
testcase_43 AC 525 ms
58,336 KB
testcase_44 AC 558 ms
58,340 KB
testcase_45 WA -
testcase_46 AC 518 ms
58,280 KB
testcase_47 AC 531 ms
58,344 KB
testcase_48 AC 524 ms
58,304 KB
testcase_49 AC 525 ms
58,248 KB
testcase_50 WA -
testcase_51 AC 521 ms
58,360 KB
testcase_52 WA -
testcase_53 AC 523 ms
58,252 KB
testcase_54 AC 525 ms
58,308 KB
testcase_55 WA -
testcase_56 AC 514 ms
58,372 KB
testcase_57 WA -
testcase_58 AC 518 ms
58,392 KB
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

d, l, r, k = map(int, input().split())
mod = 10**9 + 7
depthl = 0
depthr = 0
for i in range(30):
    if 2**i <= l < 2**(i+1):
        depthl = i+1

for i in range(30):
    if 2**i <= r < 2**(i+1):
        depthr = i+1
ans = 0
power = [1 for i in range(10**6*2)]
for i in range(1, 10**6+10**5):
    power[i] = power[i-1]*i
    power[i] %= mod

for i in range(1, d+1):
    # lcaの高さを固定
    lca = i
    res = 2*pow(2, lca-1, mod)
    if depthl+depthr-2*lca != k:
        continue
    if depthl < lca:
        continue
    if lca < depthl:
        res = res*pow(2, depthl-lca-1, mod)*pow(2, depthr-lca-1, mod)
        D = {depth: 2**(depth-1) for depth in range(1, d+1)}
        D[depthr] -= 1
        D[depthl] -= 1
        D[lca] -= 1
        for depth in D.keys():
            res *= power[D[depth]]
            res %= mod
    elif lca == depthl:
        res *= pow(2, depthr-lca-1, mod)
        D = {depth: 2**(depth-1) for depth in range(1, d+1)}
        D[depthr] -= 1
        D[lca] -= 1
        for depth in D.keys():
            res *= power[D[depth]]
            res %= mod
    ans += res
    ans %= mod
print(ans%mod)
0