結果

問題 No.1243 約数加算
ユーザー 👑 H20H20
提出日時 2021-04-13 09:51:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 977 bytes
コンパイル時間 294 ms
コンパイル使用メモリ 87,256 KB
実行使用メモリ 79,012 KB
最終ジャッジ日時 2023-09-11 13:54:36
合計ジャッジ時間 3,408 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,584 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 110 ms
77,908 KB
testcase_09 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
T = int(input())
for _ in range(T):
    A,B = map(int,input().split())
    ANS = []
    if int(math.log2(A))!=int(math.log2(B)):
        if math.log2(A) != int(math.log2(A)):
            for i in range(math.ceil(math.log2(A))):
                if 2**i & A == 2**i:
                    A += 2**i
                    ANS.append(2**i)
        while int(math.log2(A))!=int(math.log2(B)):
            ANS.append(A)
            A*=2
        AB = format(A, 'b')
        for i in range(len(AB)):
            AB = format(A, 'b')
            BB = format(B, 'b')
            if AB[i] != BB[i]:
                ANS.append(2**(len(AB)-i-1))
                A+=2**(len(AB)-i-1)
    else:
        AB = format(A, 'b')
        for i in reversed(range(len(AB))):
            AB = format(A, 'b')
            BB = format(B, 'b')
            if AB[i] != BB[i]:
                A += (2**(len(AB)-i-1))
                ANS.append((2**(len(AB)-i-1)))

    print(len(ANS))
    print(*ANS)

0