結果

問題 No.916 Encounter On A Tree
ユーザー mkawa2mkawa2
提出日時 2019-10-27 09:01:45
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 852 bytes
コンパイル時間 117 ms
コンパイル使用メモリ 10,764 KB
実行使用メモリ 49,396 KB
最終ジャッジ日時 2023-10-12 22:48:36
合計ジャッジ時間 15,865 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 192 ms
49,304 KB
testcase_01 AC 192 ms
49,192 KB
testcase_02 AC 194 ms
49,320 KB
testcase_03 AC 195 ms
49,288 KB
testcase_04 AC 193 ms
49,148 KB
testcase_05 WA -
testcase_06 AC 195 ms
49,316 KB
testcase_07 AC 194 ms
49,292 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 192 ms
49,232 KB
testcase_11 WA -
testcase_12 AC 194 ms
49,188 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 193 ms
49,172 KB
testcase_17 WA -
testcase_18 AC 193 ms
49,240 KB
testcase_19 AC 196 ms
49,340 KB
testcase_20 AC 194 ms
49,148 KB
testcase_21 WA -
testcase_22 AC 196 ms
49,236 KB
testcase_23 WA -
testcase_24 AC 196 ms
49,348 KB
testcase_25 AC 195 ms
49,304 KB
testcase_26 AC 194 ms
49,308 KB
testcase_27 AC 193 ms
49,368 KB
testcase_28 AC 194 ms
49,228 KB
testcase_29 WA -
testcase_30 AC 193 ms
49,192 KB
testcase_31 RE -
testcase_32 AC 193 ms
49,240 KB
testcase_33 WA -
testcase_34 AC 194 ms
49,192 KB
testcase_35 AC 194 ms
49,224 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 AC 197 ms
49,308 KB
testcase_42 AC 196 ms
49,308 KB
testcase_43 AC 196 ms
49,208 KB
testcase_44 AC 195 ms
49,336 KB
testcase_45 AC 195 ms
49,252 KB
testcase_46 AC 194 ms
49,308 KB
testcase_47 WA -
testcase_48 AC 195 ms
49,276 KB
testcase_49 WA -
testcase_50 AC 195 ms
49,188 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 195 ms
49,188 KB
testcase_55 AC 196 ms
49,252 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

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
    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) - w] * w) % md
        else:
            ans = (ans * fac[pow(2, i, md)]) % md
    print(ans)

main()
0