結果
| 問題 |
No.2125 Inverse Sum
|
| コンテスト | |
| ユーザー |
pitP
|
| 提出日時 | 2022-11-19 02:06:32 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 610 bytes |
| コンパイル時間 | 153 ms |
| コンパイル使用メモリ | 81,884 KB |
| 実行使用メモリ | 65,076 KB |
| 最終ジャッジ日時 | 2024-09-20 06:01:27 |
| 合計ジャッジ時間 | 4,029 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 3 WA * 1 TLE * 1 -- * 25 |
ソースコード
def fact(num):
i=2
ans=dict()
while i*i <=num:
while num%i==0:
num=num//i
if i in ans:
ans[i]+=1
else:
ans[i]=1
i+=1
if num!=1:
ans[num]=1
return ans
from math import gcd
p,q = map(int,input().split())
g = gcd(p,q)
p = p // g
q = q // g
fac = fact(q**2)
nums = [1] + [key for key,_ in fac.items()]
ans = []
for key in nums:
pn = q**2//key + q
pm = (q**2)//(pn - q) + q
if pn % p == 0 and pm % p == 0:
ans.append([pn // p ,pm // p])
if (pn//p != pm//p):
ans.append([pm // p ,pn // p])
ans.sort()
print(len(ans))
for l in ans:
print(*l)
pitP