結果
| 問題 |
No.1243 約数加算
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-10-01 08:21:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 587 bytes |
| コンパイル時間 | 157 ms |
| コンパイル使用メモリ | 82,596 KB |
| 実行使用メモリ | 72,220 KB |
| 最終ジャッジ日時 | 2024-07-18 13:52:03 |
| 合計ジャッジ時間 | 2,293 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 9 |
ソースコード
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:
g=gcd(a,b)
op.append(g)
a//=g
b//=g
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)