結果
| 問題 |
No.1243 約数加算
|
| コンテスト | |
| ユーザー |
mkawa2
|
| 提出日時 | 2020-10-02 23:09:41 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,559 bytes |
| コンパイル時間 | 259 ms |
| コンパイル使用メモリ | 82,564 KB |
| 実行使用メモリ | 68,468 KB |
| 最終ジャッジ日時 | 2024-07-17 23:25:19 |
| 合計ジャッジ時間 | 4,246 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 4 TLE * 1 -- * 4 |
ソースコード
from operator import itemgetter
from itertools import *
from bisect import *
from collections import *
from heapq import *
import sys
sys.setrecursionlimit(10**6)
int1 = lambda x: int(x)-1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.buffer.readline())
def MI(): return map(int, sys.stdin.buffer.readline().split())
def MI1(): return map(int1, sys.stdin.buffer.readline().split())
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def LI1(): return list(map(int1, sys.stdin.buffer.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.buffer.readline()[:-1]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]
dij = [(1, 0), (0, 1), (-1, 0), (0, -1)]
def factors(a):
if a<=0:return [0]
low=[]
high=[]
for d in range(1,a+1):
if d*d>a:break
if a%d:continue
low.append(d)
high.append(a//d)
if low[-1]==high[-1]:high.pop()
return low+high[::-1]
def nearf(a,s):
if a<=s:return a
if s**2<a:
for d in range(s,0,-1):
if a%d==0:return d
else:
s1=(a+s-1)//s
# print(a,s,s1)
for d in range(s1,a+1):
if d**2>a:break
if a%d==0:return a//d
for d in range(s1,0,-1):
if a%d==0:return d
def solve(a,b):
ans=[]
while a<b:
f=nearf(a,b-a)
ans.append(f)
# print(a,b-a,f,ans)
a+=f
print(len(ans))
print(*ans)
for _ in range(II()):
a,b=MI()
solve(a,b)
mkawa2