結果

問題 No.3624 Product
コンテスト
ユーザー LyricalMaestro
提出日時 2026-08-18 02:34:54
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 139 ms / 2,000 ms
+ 527µs
コード長 616 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 260 ms
コンパイル使用メモリ 96,236 KB
実行使用メモリ 88,164 KB
最終ジャッジ日時 2026-08-18 02:35:04
合計ジャッジ時間 3,314 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 12
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

# https://yukicoder.me/problems/no/3622
 
def solve(L, R):
    k_l = 0
    while L >0:
        k_l += 1
        L //= 2

    k_r = 0
    while R > 0:
        k_r += 1
        R //= 2

    if k_l == k_r:
        if k_l == 0:
            return 0
        else:
            return -1
    ans = 1 << (k_r - 1)
    ans2 = (1 << (k_r - 1)) - 1
    return ans * ans2



def main():
    T = int(input())
    answers = []
    for _ in range(T):
        L, R= map(int, input().split())
        ans = solve(L, R)
        answers.append(ans)


    for ans in answers:
        print(ans)




if __name__ == "__main__":
    main()
0