結果

問題 No.3624 Product
コンテスト
ユーザー LyricalMaestro
提出日時 2026-08-18 02:31:30
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 555 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 256 ms
コンパイル使用メモリ 95,976 KB
実行使用メモリ 88,272 KB
最終ジャッジ日時 2026-08-18 02:31:41
合計ジャッジ時間 3,164 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 7 WA * 5
権限があれば一括ダウンロードができます

ソースコード

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:
        return -1

    ans = 1 << (k_r - 1)
    ans2 = 2 ** (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