結果

問題 No.916 Encounter On A Tree
ユーザー ttrttr
提出日時 2020-02-19 19:39:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 774 bytes
コンパイル時間 87 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 51,840 KB
最終ジャッジ日時 2024-04-17 04:42:54
合計ジャッジ時間 14,231 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 32 ms
10,752 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 385 ms
51,840 KB
testcase_03 AC 393 ms
51,840 KB
testcase_04 AC 393 ms
51,712 KB
testcase_05 WA -
testcase_06 AC 375 ms
51,840 KB
testcase_07 AC 382 ms
51,712 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 30 ms
10,752 KB
testcase_11 WA -
testcase_12 AC 375 ms
51,712 KB
testcase_13 WA -
testcase_14 AC 395 ms
51,840 KB
testcase_15 WA -
testcase_16 AC 122 ms
20,992 KB
testcase_17 WA -
testcase_18 AC 29 ms
10,752 KB
testcase_19 AC 388 ms
51,712 KB
testcase_20 AC 392 ms
51,712 KB
testcase_21 WA -
testcase_22 AC 394 ms
51,712 KB
testcase_23 WA -
testcase_24 AC 402 ms
51,840 KB
testcase_25 AC 394 ms
51,840 KB
testcase_26 AC 211 ms
31,360 KB
testcase_27 AC 215 ms
31,360 KB
testcase_28 AC 122 ms
20,864 KB
testcase_29 WA -
testcase_30 AC 395 ms
51,840 KB
testcase_31 AC 397 ms
51,712 KB
testcase_32 AC 371 ms
51,840 KB
testcase_33 AC 206 ms
31,356 KB
testcase_34 AC 121 ms
20,864 KB
testcase_35 AC 75 ms
15,872 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 394 ms
51,712 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 29 ms
10,752 KB
testcase_43 AC 29 ms
10,752 KB
testcase_44 AC 28 ms
10,752 KB
testcase_45 AC 71 ms
15,744 KB
testcase_46 AC 28 ms
10,752 KB
testcase_47 WA -
testcase_48 AC 27 ms
10,752 KB
testcase_49 WA -
testcase_50 AC 26 ms
10,752 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 WA -
testcase_54 AC 29 ms
10,752 KB
testcase_55 AC 29 ms
10,752 KB
testcase_56 WA -
testcase_57 WA -
testcase_58 WA -
testcase_59 WA -
testcase_60 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

d,l,r,k = map(int, input().split())

mod = 10**9+7

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

j = 1
while j <= d:
    if 2**(j-1) <= l < 2**j:
        jl = j
    if 2**(j-1) <= r < 2**j:
        jr = j
    j += 1

if (jr-jl)%2 == k%2 and jr-jl <= k <= jr-jl+2*(jl-1):
    t = k-(jr-jl)
    ans = 1
    for i in range(1, d+1):
        if i == jr and jl != jr:
            if t <= 4:
                ans *= 2**(jr-jl)*P[2**(i-1)]
            else:
                ans *= 2**(jr-jl+t//2)*P[2**(i-1)]
            ans %= mod
            continue
        elif i == jr:
            ans *= 2**(i-1)*2**(t//2-1)*P[2**(i-1)-2]
            ans %= mod
            continue
        ans *= P[2**(i-1)]
        ans %= mod
else:
    ans = 0

print(ans)
0