結果

問題 No.1243 約数加算
ユーザー wolgnikwolgnik
提出日時 2020-10-02 21:56:26
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 97 ms / 2,000 ms
コード長 444 bytes
コンパイル時間 1,691 ms
コンパイル使用メモリ 86,772 KB
実行使用メモリ 76,528 KB
最終ジャッジ日時 2023-09-23 04:54:54
合計ジャッジ時間 2,138 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
71,132 KB
testcase_01 AC 74 ms
71,040 KB
testcase_02 AC 75 ms
71,208 KB
testcase_03 AC 73 ms
70,984 KB
testcase_04 AC 97 ms
76,392 KB
testcase_05 AC 94 ms
76,384 KB
testcase_06 AC 94 ms
76,500 KB
testcase_07 AC 92 ms
76,528 KB
testcase_08 AC 94 ms
76,512 KB
testcase_09 AC 75 ms
71,140 KB
権限があれば一括ダウンロードができます

ソースコード

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