結果

問題 No.1243 約数加算
ユーザー SPD_9X2
提出日時 2020-10-02 21:54:56
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 539 bytes
コンパイル時間 207 ms
コンパイル使用メモリ 81,860 KB
実行使用メモリ 69,164 KB
最終ジャッジ日時 2024-07-16 04:54:27
合計ジャッジ時間 1,209 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin
import sys

TT = int(stdin.readline())

for loop in range(TT):

    A,B = map(int,stdin.readline().split())
    ans = []

    cnt = 1
    while True:

        if A + cnt > B:
            break

        if A % (cnt * 2) == 0:
            cnt *= 2
        else:
            ans.append(cnt)
            A += cnt
            cnt *= 2

    for i in range(70,-1,-1):

        j = 2**i
        if A + j <= B:
            ans.append(j)
            A += j

    print (A,B,file=sys.stderr)
    print (len(ans))
    print (*ans)
0