結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 150 ms
110,928 KB
testcase_01 AC 151 ms
110,652 KB
testcase_02 AC 151 ms
110,748 KB
testcase_03 AC 150 ms
110,648 KB
testcase_04 AC 150 ms
110,936 KB
testcase_05 WA -
testcase_06 AC 151 ms
110,740 KB
testcase_07 AC 150 ms
110,764 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 148 ms
110,876 KB
testcase_11 AC 152 ms
110,880 KB
testcase_12 AC 151 ms
110,952 KB
testcase_13 AC 148 ms
110,760 KB
testcase_14 AC 148 ms
110,736 KB
testcase_15 AC 150 ms
110,656 KB
testcase_16 AC 153 ms
110,748 KB
testcase_17 WA -
testcase_18 AC 151 ms
110,748 KB
testcase_19 AC 153 ms
110,988 KB
testcase_20 AC 151 ms
110,656 KB
testcase_21 WA -
testcase_22 AC 148 ms
110,912 KB
testcase_23 WA -
testcase_24 AC 149 ms
110,780 KB
testcase_25 AC 152 ms
110,760 KB
testcase_26 AC 149 ms
110,860 KB
testcase_27 AC 148 ms
110,820 KB
testcase_28 AC 149 ms
110,772 KB
testcase_29 WA -
testcase_30 AC 147 ms
110,992 KB
testcase_31 AC 148 ms
110,708 KB
testcase_32 AC 150 ms
111,060 KB
testcase_33 AC 149 ms
110,928 KB
testcase_34 AC 150 ms
110,708 KB
testcase_35 AC 148 ms
110,780 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 150 ms
110,892 KB
testcase_40 WA -
testcase_41 AC 149 ms
111,064 KB
testcase_42 AC 148 ms
110,656 KB
testcase_43 AC 147 ms
110,656 KB
testcase_44 AC 151 ms
111,064 KB
testcase_45 AC 152 ms
110,832 KB
testcase_46 AC 150 ms
110,804 KB
testcase_47 AC 149 ms
110,720 KB
testcase_48 AC 150 ms
110,920 KB
testcase_49 AC 147 ms
110,960 KB
testcase_50 AC 152 ms
110,916 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 149 ms
110,956 KB
testcase_54 AC 150 ms
110,960 KB
testcase_55 AC 155 ms
110,660 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
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, dl + par, mod), mod-1, 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