結果

問題 No.916 Encounter On A Tree
ユーザー ptotqptotq
提出日時 2019-10-25 22:57:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 800 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 10,796 KB
実行使用メモリ 28,688 KB
最終ジャッジ日時 2023-10-11 07:40:17
合計ジャッジ時間 9,009 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,784 KB
testcase_01 AC 16 ms
7,780 KB
testcase_02 AC 191 ms
28,540 KB
testcase_03 AC 188 ms
28,484 KB
testcase_04 AC 186 ms
28,436 KB
testcase_05 WA -
testcase_06 AC 189 ms
28,444 KB
testcase_07 AC 182 ms
28,492 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 16 ms
7,736 KB
testcase_11 AC 16 ms
7,792 KB
testcase_12 AC 186 ms
28,508 KB
testcase_13 AC 187 ms
28,596 KB
testcase_14 AC 187 ms
28,408 KB
testcase_15 AC 186 ms
28,620 KB
testcase_16 AC 59 ms
13,212 KB
testcase_17 WA -
testcase_18 AC 16 ms
7,736 KB
testcase_19 AC 191 ms
28,532 KB
testcase_20 AC 187 ms
28,492 KB
testcase_21 WA -
testcase_22 AC 187 ms
28,600 KB
testcase_23 WA -
testcase_24 AC 188 ms
28,568 KB
testcase_25 AC 186 ms
28,600 KB
testcase_26 AC 102 ms
18,388 KB
testcase_27 AC 105 ms
18,212 KB
testcase_28 AC 61 ms
13,192 KB
testcase_29 WA -
testcase_30 AC 193 ms
28,552 KB
testcase_31 AC 187 ms
28,500 KB
testcase_32 AC 187 ms
28,436 KB
testcase_33 AC 103 ms
18,232 KB
testcase_34 AC 59 ms
13,252 KB
testcase_35 AC 38 ms
10,708 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 189 ms
28,480 KB
testcase_40 WA -
testcase_41 AC 16 ms
7,856 KB
testcase_42 AC 16 ms
7,708 KB
testcase_43 AC 16 ms
7,860 KB
testcase_44 AC 16 ms
7,740 KB
testcase_45 AC 38 ms
10,528 KB
testcase_46 AC 16 ms
7,708 KB
testcase_47 AC 16 ms
7,756 KB
testcase_48 AC 16 ms
7,776 KB
testcase_49 AC 16 ms
7,732 KB
testcase_50 AC 16 ms
7,816 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 16 ms
7,748 KB
testcase_54 AC 16 ms
7,708 KB
testcase_55 AC 16 ms
7,796 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
ans = 1
fac = [1]*(2**(d-1)+1)
for i in range(1, 2**(d-1)+1):
    fac[i] = (fac[i-1] * i) % mod
depth1, depth2 = -1, -1

for depth in range(d):
    i_l, i_r = 2**depth, 2**(depth+1)-1
    nodes = 2**depth
    if i_l <= l <= i_r:
        depth1 = depth
        nodes -= 1
    if i_l <= r <= i_r:
        depth2 = depth
        nodes -= 1

    ans = (ans * fac[nodes]) % mod

if depth1 != depth2:
    if abs(depth1 - depth2) != k:
        ans = 0
    else:
        ans = ans * pow(2, depth1, mod) * pow(2, depth2, mod) % mod
else:
    if k % 2 == 1 or (d-1)*2 < k:
        ans = 0
    else:
        nodes = 2 ** depth1
        unit = 2 ** (k//2)
        n = nodes // unit
        ans = ans * (pow(unit//2, 2, mod) * n) * 2 % mod

print(ans % mod)
0