結果

問題 No.916 Encounter On A Tree
ユーザー ttrttr
提出日時 2020-02-19 19:52:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 423 ms / 2,000 ms
コード長 779 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 51,968 KB
最終ジャッジ日時 2024-04-17 05:00:26
合計ジャッジ時間 14,626 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,880 KB
testcase_01 AC 30 ms
10,752 KB
testcase_02 AC 413 ms
51,956 KB
testcase_03 AC 418 ms
51,840 KB
testcase_04 AC 399 ms
51,840 KB
testcase_05 AC 395 ms
51,840 KB
testcase_06 AC 396 ms
51,840 KB
testcase_07 AC 422 ms
51,840 KB
testcase_08 AC 79 ms
15,872 KB
testcase_09 AC 123 ms
20,992 KB
testcase_10 AC 31 ms
10,752 KB
testcase_11 AC 32 ms
10,752 KB
testcase_12 AC 415 ms
51,932 KB
testcase_13 AC 403 ms
51,840 KB
testcase_14 AC 413 ms
51,860 KB
testcase_15 AC 394 ms
51,840 KB
testcase_16 AC 126 ms
20,992 KB
testcase_17 AC 397 ms
51,944 KB
testcase_18 AC 32 ms
10,880 KB
testcase_19 AC 395 ms
51,848 KB
testcase_20 AC 399 ms
51,840 KB
testcase_21 AC 413 ms
51,840 KB
testcase_22 AC 417 ms
51,840 KB
testcase_23 AC 400 ms
51,964 KB
testcase_24 AC 402 ms
51,908 KB
testcase_25 AC 396 ms
51,860 KB
testcase_26 AC 212 ms
31,416 KB
testcase_27 AC 216 ms
31,316 KB
testcase_28 AC 123 ms
20,992 KB
testcase_29 AC 394 ms
51,940 KB
testcase_30 AC 423 ms
51,968 KB
testcase_31 AC 411 ms
51,840 KB
testcase_32 AC 403 ms
51,840 KB
testcase_33 AC 229 ms
31,360 KB
testcase_34 AC 129 ms
21,120 KB
testcase_35 AC 79 ms
15,872 KB
testcase_36 AC 405 ms
51,840 KB
testcase_37 AC 409 ms
51,952 KB
testcase_38 AC 124 ms
20,992 KB
testcase_39 AC 393 ms
51,840 KB
testcase_40 AC 398 ms
51,840 KB
testcase_41 AC 31 ms
10,752 KB
testcase_42 AC 30 ms
10,752 KB
testcase_43 AC 29 ms
10,752 KB
testcase_44 AC 29 ms
10,880 KB
testcase_45 AC 76 ms
16,000 KB
testcase_46 AC 30 ms
10,880 KB
testcase_47 AC 30 ms
10,752 KB
testcase_48 AC 30 ms
10,752 KB
testcase_49 AC 29 ms
10,752 KB
testcase_50 AC 29 ms
10,752 KB
testcase_51 AC 30 ms
10,880 KB
testcase_52 AC 31 ms
10,880 KB
testcase_53 AC 31 ms
10,880 KB
testcase_54 AC 30 ms
10,880 KB
testcase_55 AC 31 ms
10,752 KB
testcase_56 AC 31 ms
10,880 KB
testcase_57 AC 33 ms
10,880 KB
testcase_58 AC 33 ms
11,136 KB
testcase_59 AC 36 ms
11,520 KB
testcase_60 AC 43 ms
12,032 KB
権限があれば一括ダウンロードができます

ソースコード

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)-1]
            else:
                ans *= 2**(jr-jl+t//2-1)*P[2**(i-1)-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