結果

問題 No.1243 約数加算
ユーザー wolgnik
提出日時 2020-10-02 21:56:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 62 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 352 ms
コンパイル使用メモリ 82,388 KB
実行使用メモリ 67,492 KB
最終ジャッジ日時 2024-07-16 04:56:53
合計ジャッジ時間 1,549 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
for _ in range(int(input())):
  a, b = map(int, input().split())
  if b - a <= 120:
    print(b - a)
    print(*[1] * (b - a))
    continue
  r = len(bin(a ^ b)) - 3
  res = []
  x = 0
  while x < r:
    if a & (1 << x):
      res.append(1 << x)
      a += 1 << x
    x += 1
  x -= 1
  while x >= 0:
    if b & (1 << x):
      res.append(1 << x)
      a += 1 << x
    x -= 1
  print(len(res))
  print(*res)
0