結果

問題 No.916 Encounter On A Tree
ユーザー tktk_snsntktk_snsn
提出日時 2020-12-30 15:43:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 58 ms / 2,000 ms
コード長 542 bytes
コンパイル時間 181 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 57,984 KB
最終ジャッジ日時 2024-04-16 17:11:17
合計ジャッジ時間 4,904 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 45 ms
51,584 KB
testcase_01 AC 42 ms
51,584 KB
testcase_02 AC 42 ms
51,712 KB
testcase_03 AC 53 ms
57,600 KB
testcase_04 AC 42 ms
51,840 KB
testcase_05 AC 56 ms
57,728 KB
testcase_06 AC 41 ms
51,840 KB
testcase_07 AC 53 ms
57,728 KB
testcase_08 AC 47 ms
57,856 KB
testcase_09 AC 48 ms
57,728 KB
testcase_10 AC 42 ms
52,096 KB
testcase_11 AC 43 ms
51,968 KB
testcase_12 AC 42 ms
51,840 KB
testcase_13 AC 54 ms
57,856 KB
testcase_14 AC 45 ms
51,968 KB
testcase_15 AC 54 ms
57,856 KB
testcase_16 AC 42 ms
52,096 KB
testcase_17 AC 52 ms
57,856 KB
testcase_18 AC 43 ms
51,712 KB
testcase_19 AC 54 ms
57,856 KB
testcase_20 AC 41 ms
51,840 KB
testcase_21 AC 53 ms
57,984 KB
testcase_22 AC 42 ms
51,968 KB
testcase_23 AC 54 ms
57,856 KB
testcase_24 AC 43 ms
51,840 KB
testcase_25 AC 58 ms
57,728 KB
testcase_26 AC 42 ms
51,968 KB
testcase_27 AC 50 ms
57,728 KB
testcase_28 AC 42 ms
51,968 KB
testcase_29 AC 54 ms
57,984 KB
testcase_30 AC 42 ms
52,480 KB
testcase_31 AC 42 ms
51,584 KB
testcase_32 AC 42 ms
51,840 KB
testcase_33 AC 42 ms
52,096 KB
testcase_34 AC 48 ms
57,600 KB
testcase_35 AC 48 ms
57,856 KB
testcase_36 AC 55 ms
57,728 KB
testcase_37 AC 54 ms
57,600 KB
testcase_38 AC 47 ms
57,728 KB
testcase_39 AC 42 ms
51,968 KB
testcase_40 AC 53 ms
57,728 KB
testcase_41 AC 41 ms
51,968 KB
testcase_42 AC 42 ms
51,968 KB
testcase_43 AC 43 ms
51,968 KB
testcase_44 AC 42 ms
51,840 KB
testcase_45 AC 49 ms
57,600 KB
testcase_46 AC 44 ms
51,968 KB
testcase_47 AC 43 ms
51,584 KB
testcase_48 AC 42 ms
51,968 KB
testcase_49 AC 42 ms
51,584 KB
testcase_50 AC 42 ms
52,096 KB
testcase_51 AC 41 ms
52,352 KB
testcase_52 AC 42 ms
51,968 KB
testcase_53 AC 42 ms
51,840 KB
testcase_54 AC 43 ms
51,712 KB
testcase_55 AC 43 ms
52,096 KB
testcase_56 AC 46 ms
57,856 KB
testcase_57 AC 46 ms
57,984 KB
testcase_58 AC 46 ms
57,856 KB
testcase_59 AC 47 ms
57,728 KB
testcase_60 AC 47 ms
57,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 10 ** 9 + 7
D, L, R, K = map(int, input().split())

dl = L.bit_length()
dr = R.bit_length()
for lca in range(1, dl + 1):
    if dr + dl - 2 * lca == K:
        break
else:
    print(0)
    exit()


ans = pow(2, lca - 1, mod)
if dl == lca:
    ans *= pow(2, dr - lca, mod)
    ans %= mod
else:
    ans *= pow(2, dl - lca, mod)
    ans *= pow(2, dr - lca - 1, mod)
    ans %= mod

cnt = [1 << i for i in range(D)]
cnt[dl - 1] -= 1
cnt[dr - 1] -= 1
for c in cnt:
    for i in range(2, c + 1):
        ans *= i
        ans %= mod
print(ans)
0