結果

問題 No.1243 約数加算
ユーザー raven7959raven7959
提出日時 2021-10-01 08:27:14
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 570 bytes
コンパイル時間 1,007 ms
コンパイル使用メモリ 87,132 KB
実行使用メモリ 77,064 KB
最終ジャッジ日時 2023-09-25 17:50:37
合計ジャッジ時間 4,314 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

from math import gcd
t=int(input())
for _ in range(t):
  a,b=map(int,input().split())
  op=[]
  while b-a>=2:
    if a%2==0 and b%2==0:
      op.append(2)
      a//=2
      b//=2
    elif a%2==0:
      op.append(-1)
      b-=1
    elif b%2==0:
      op.append(1)
      a+=1
    else:
      op.append(1)
      op.append(-1)
      a+=1
      b-=1
  if b-a==1:
    op.append(1)
  by=1
  plus=[]
  minus=[]
  for num in op:
    if num==1:
      plus.append(by)
    elif num==-1:
      minus.append(by)
    else:
      by*=num
  ANS=plus+minus
  print(len(ANS))
  print(*ANS)
0