結果

問題 No.916 Encounter On A Tree
ユーザー mkawa2mkawa2
提出日時 2019-10-27 09:10:46
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 870 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 10,916 KB
実行使用メモリ 49,352 KB
最終ジャッジ日時 2023-10-12 22:49:09
合計ジャッジ時間 14,704 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 196 ms
49,180 KB
testcase_01 AC 193 ms
49,304 KB
testcase_02 AC 193 ms
49,168 KB
testcase_03 AC 192 ms
49,208 KB
testcase_04 AC 194 ms
49,304 KB
testcase_05 AC 194 ms
49,180 KB
testcase_06 AC 192 ms
49,316 KB
testcase_07 AC 193 ms
49,312 KB
testcase_08 AC 197 ms
49,308 KB
testcase_09 AC 192 ms
49,180 KB
testcase_10 AC 198 ms
49,280 KB
testcase_11 AC 194 ms
49,312 KB
testcase_12 AC 195 ms
49,256 KB
testcase_13 AC 193 ms
49,136 KB
testcase_14 WA -
testcase_15 AC 194 ms
49,200 KB
testcase_16 AC 200 ms
49,180 KB
testcase_17 AC 195 ms
49,144 KB
testcase_18 AC 192 ms
49,144 KB
testcase_19 AC 192 ms
49,256 KB
testcase_20 AC 195 ms
49,140 KB
testcase_21 AC 194 ms
49,252 KB
testcase_22 AC 194 ms
49,304 KB
testcase_23 AC 198 ms
49,264 KB
testcase_24 AC 196 ms
49,160 KB
testcase_25 AC 193 ms
49,184 KB
testcase_26 AC 199 ms
49,176 KB
testcase_27 AC 194 ms
49,252 KB
testcase_28 AC 195 ms
49,352 KB
testcase_29 AC 194 ms
49,316 KB
testcase_30 AC 195 ms
49,180 KB
testcase_31 WA -
testcase_32 AC 195 ms
49,268 KB
testcase_33 WA -
testcase_34 AC 195 ms
49,332 KB
testcase_35 AC 194 ms
49,316 KB
testcase_36 AC 194 ms
49,336 KB
testcase_37 AC 193 ms
49,148 KB
testcase_38 AC 195 ms
49,240 KB
testcase_39 WA -
testcase_40 AC 195 ms
49,200 KB
testcase_41 AC 195 ms
49,196 KB
testcase_42 AC 195 ms
49,244 KB
testcase_43 AC 194 ms
49,316 KB
testcase_44 AC 196 ms
49,248 KB
testcase_45 AC 195 ms
49,180 KB
testcase_46 AC 195 ms
49,140 KB
testcase_47 AC 195 ms
49,324 KB
testcase_48 AC 195 ms
49,200 KB
testcase_49 AC 197 ms
49,272 KB
testcase_50 AC 195 ms
49,192 KB
testcase_51 AC 195 ms
49,272 KB
testcase_52 AC 196 ms
49,204 KB
testcase_53 AC 195 ms
49,136 KB
testcase_54 AC 195 ms
49,212 KB
testcase_55 AC 196 ms
49,316 KB
testcase_56 AC 198 ms
49,316 KB
testcase_57 AC 196 ms
49,276 KB
testcase_58 AC 197 ms
49,324 KB
testcase_59 AC 196 ms
49,308 KB
testcase_60 AC 195 ms
49,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    md = 10 ** 9 + 7
    d, l, r, k = map(int, input().split())
    mx = pow(2, 20) + 5
    fac = [1] * mx
    for i in range(1, mx):
        fac[i] = (fac[i - 1] * i) % md

    d0 = d1 = 0
    while l:
        l //= 2
        d0 += 1
    while r:
        r //= 2
        d1 += 1
    #print(d0,d1)
    c = k - (d1 - d0)
    if c < 0 or c % 2:
        print(0)
        exit()
    h = k - c // 2
    if c > 0: h -= 1
    ans = 1
    for i in range(d):
        if i + 1 == d1:
            w = pow(2, h, md)
            if d0 == d1:
                pw = pow(2, i, md)
                ans = (ans * pw * w * fac[pw - 2]) % md
            else:
                ans = (ans * fac[pow(2, i, md) - 1] * w) % md
        else:
            ans = (ans * fac[pow(2, i, md)]) % md
    print(ans)

main()
0