結果

問題 No.1243 約数加算
ユーザー neterukunneterukun
提出日時 2020-10-02 23:23:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 558 bytes
コンパイル時間 1,426 ms
コンパイル使用メモリ 86,752 KB
実行使用メモリ 76,780 KB
最終ジャッジ日時 2023-09-24 23:35:41
合計ジャッジ時間 3,048 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,156 KB
testcase_01 AC 72 ms
71,496 KB
testcase_02 AC 73 ms
71,384 KB
testcase_03 AC 74 ms
71,360 KB
testcase_04 AC 99 ms
76,684 KB
testcase_05 AC 100 ms
76,632 KB
testcase_06 AC 97 ms
76,728 KB
testcase_07 AC 95 ms
76,780 KB
testcase_08 AC 95 ms
76,728 KB
testcase_09 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

t = int(input())
for _ in range(t):
    a, b = map(int, input().split())
    ans = []
    
    len_b = len(bin(b)) - 2
    len_a = len(bin(a)) - 2
    for i in range(100)[::-1]:
        if a & (1 << i) != b & (1 << i):
            len_b = i + 1
            break
        
    for i in range(len_b - 1):
        if a & (1 << i):
            a += 1 << i
            ans.append(1 << i)
    for i in range(len_b - 1)[::-1]:
        if a & (1 << i) != b & (1 << i):
            a += (1 << i)
            ans.append(1 << i)
    print(len(ans))
    print(*ans)
    
0