結果

問題 No.916 Encounter On A Tree
ユーザー tpynerivertpyneriver
提出日時 2019-10-28 15:12:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,026 bytes
コンパイル時間 1,211 ms
コンパイル使用メモリ 86,968 KB
実行使用メモリ 111,432 KB
最終ジャッジ日時 2023-10-12 23:05:31
合計ジャッジ時間 11,682 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
110,984 KB
testcase_01 AC 151 ms
111,152 KB
testcase_02 AC 149 ms
110,908 KB
testcase_03 AC 150 ms
111,072 KB
testcase_04 AC 149 ms
111,108 KB
testcase_05 WA -
testcase_06 AC 149 ms
111,084 KB
testcase_07 AC 147 ms
111,196 KB
testcase_08 AC 147 ms
110,956 KB
testcase_09 AC 149 ms
111,152 KB
testcase_10 AC 152 ms
111,144 KB
testcase_11 AC 150 ms
110,948 KB
testcase_12 AC 149 ms
111,104 KB
testcase_13 AC 149 ms
111,052 KB
testcase_14 AC 149 ms
111,152 KB
testcase_15 AC 150 ms
111,152 KB
testcase_16 AC 151 ms
111,084 KB
testcase_17 WA -
testcase_18 AC 150 ms
111,004 KB
testcase_19 AC 151 ms
111,168 KB
testcase_20 AC 153 ms
111,232 KB
testcase_21 WA -
testcase_22 AC 151 ms
110,912 KB
testcase_23 WA -
testcase_24 AC 147 ms
110,988 KB
testcase_25 AC 151 ms
111,152 KB
testcase_26 AC 152 ms
111,320 KB
testcase_27 AC 150 ms
111,032 KB
testcase_28 AC 151 ms
111,028 KB
testcase_29 WA -
testcase_30 AC 149 ms
111,080 KB
testcase_31 AC 150 ms
111,248 KB
testcase_32 AC 150 ms
110,908 KB
testcase_33 AC 154 ms
111,028 KB
testcase_34 AC 150 ms
111,112 KB
testcase_35 AC 152 ms
111,028 KB
testcase_36 AC 151 ms
111,120 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 152 ms
110,984 KB
testcase_40 AC 151 ms
110,952 KB
testcase_41 AC 152 ms
111,076 KB
testcase_42 AC 151 ms
111,024 KB
testcase_43 AC 153 ms
111,148 KB
testcase_44 AC 152 ms
111,084 KB
testcase_45 AC 150 ms
111,028 KB
testcase_46 AC 152 ms
111,112 KB
testcase_47 AC 149 ms
111,104 KB
testcase_48 AC 151 ms
111,124 KB
testcase_49 AC 150 ms
111,056 KB
testcase_50 AC 150 ms
110,988 KB
testcase_51 AC 151 ms
111,248 KB
testcase_52 WA -
testcase_53 AC 151 ms
111,016 KB
testcase_54 AC 152 ms
111,184 KB
testcase_55 AC 151 ms
111,144 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 AC 150 ms
111,048 KB
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline
mod = 10**9+7

def frac(limit):
    frac = [1]*limit
    for i in range(2,limit):
        frac[i] = i * frac[i-1]%mod
    fraci = [None]*limit
    fraci[-1] = pow(frac[-1], mod -2, mod)
    for i in range(-2, -limit-1, -1):
        fraci[i] = fraci[i+1] * (limit + i + 1) % mod
    return frac, fraci
frac, fraci = frac(1341398)

def check(dl, dr, D, K):
    if dl > dr:
        dl, dr = dr, dl
    
    dist = dr - dl
    if dist > K:
        return 0
    if (K - dist) % 2 == 1:
        return 0
    if dl - (K-dist)//2 < 1:
        return 0
    if dl == dr == 1:
        return 0
    
    par = dl - (K-dist)//2
    if dl == dr:
        return pow(2, mod-2, mod)*pow(2, dr-par, mod) * pow(pow(2, dl-1, mod)-1, mod-2, mod)
    else:
        return pow(pow(2, par - 1, mod), mod-2, mod)
        
    

D, L, R, K = map(int, readline().split())

dl = L.bit_length()
dr = R.bit_length()

ans = 1
for i in range(D):
    ans = ans*frac[pow(2, i)]%mod

print(ans*check(dl, dr, D, K) %mod)
0