結果

問題 No.916 Encounter On A Tree
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2022-05-03 18:32:57
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 88 ms / 2,000 ms
コード長 673 bytes
コンパイル時間 281 ms
コンパイル使用メモリ 86,876 KB
実行使用メモリ 84,396 KB
最終ジャッジ日時 2023-09-15 11:22:31
合計ジャッジ時間 7,153 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,336 KB
testcase_01 AC 73 ms
71,500 KB
testcase_02 AC 85 ms
84,156 KB
testcase_03 AC 85 ms
84,160 KB
testcase_04 AC 85 ms
84,292 KB
testcase_05 AC 84 ms
84,024 KB
testcase_06 AC 85 ms
84,168 KB
testcase_07 AC 86 ms
84,028 KB
testcase_08 AC 79 ms
77,144 KB
testcase_09 AC 80 ms
77,836 KB
testcase_10 AC 72 ms
71,416 KB
testcase_11 AC 73 ms
71,424 KB
testcase_12 AC 86 ms
84,328 KB
testcase_13 AC 86 ms
84,192 KB
testcase_14 AC 85 ms
84,288 KB
testcase_15 AC 85 ms
84,128 KB
testcase_16 AC 78 ms
77,840 KB
testcase_17 AC 85 ms
84,128 KB
testcase_18 AC 72 ms
71,124 KB
testcase_19 AC 84 ms
83,940 KB
testcase_20 AC 86 ms
84,184 KB
testcase_21 AC 85 ms
83,988 KB
testcase_22 AC 86 ms
83,988 KB
testcase_23 AC 86 ms
84,052 KB
testcase_24 AC 88 ms
84,152 KB
testcase_25 AC 87 ms
84,136 KB
testcase_26 AC 84 ms
80,032 KB
testcase_27 AC 80 ms
80,004 KB
testcase_28 AC 77 ms
77,896 KB
testcase_29 AC 84 ms
84,020 KB
testcase_30 AC 86 ms
84,348 KB
testcase_31 AC 86 ms
83,972 KB
testcase_32 AC 84 ms
84,220 KB
testcase_33 AC 81 ms
80,088 KB
testcase_34 AC 78 ms
78,016 KB
testcase_35 AC 78 ms
76,992 KB
testcase_36 AC 85 ms
84,396 KB
testcase_37 AC 86 ms
84,324 KB
testcase_38 AC 79 ms
78,204 KB
testcase_39 AC 85 ms
84,116 KB
testcase_40 AC 86 ms
84,220 KB
testcase_41 AC 72 ms
71,176 KB
testcase_42 AC 73 ms
71,560 KB
testcase_43 AC 72 ms
71,404 KB
testcase_44 AC 74 ms
71,344 KB
testcase_45 AC 79 ms
76,852 KB
testcase_46 AC 72 ms
71,440 KB
testcase_47 AC 73 ms
71,096 KB
testcase_48 AC 73 ms
71,724 KB
testcase_49 AC 75 ms
71,684 KB
testcase_50 AC 73 ms
71,356 KB
testcase_51 AC 72 ms
71,464 KB
testcase_52 AC 73 ms
71,120 KB
testcase_53 AC 72 ms
71,540 KB
testcase_54 AC 72 ms
71,416 KB
testcase_55 AC 75 ms
71,424 KB
testcase_56 AC 78 ms
75,788 KB
testcase_57 AC 75 ms
75,824 KB
testcase_58 AC 76 ms
75,928 KB
testcase_59 AC 74 ms
76,012 KB
testcase_60 AC 77 ms
76,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

d,l,r,k = map(int,input().split())
mod = 10**9+7
ans = 0
depl = len(bin(l))-3
depr = len(bin(r))-3

fact = [1]*((1<<d)+1)
for i in range(2,(1<<d)+1):
    fact[i] = fact[i-1]*i%mod


ans = 0

for i in range(d+1):
    p = depl-i
    if p < 0:
        continue

    dif = k-i

    if dif < 0 or dif != depr-p:
        continue

    base = 1<<depl
    if i:
        base *= ((1<<depr-p) - (1<<depr-p)//2)
    else:
        base *= 1<<depr-p
    base %= mod
    for i in range(d):
        cand = 1<<i
        if i == depl:
            cand -= 1
        if i == depr:
            cand -= 1

        base *= fact[cand]
        base %= mod
    ans += base
    ans %= mod
print(ans)
0