結果
| 問題 |
No.2125 Inverse Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-11-21 19:12:26 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 463 bytes |
| コンパイル時間 | 513 ms |
| コンパイル使用メモリ | 82,772 KB |
| 実行使用メモリ | 66,304 KB |
| 最終ジャッジ日時 | 2024-09-22 10:18:28 |
| 合計ジャッジ時間 | 4,136 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 2 TLE * 1 -- * 27 |
ソースコード
import math
p, q = map(int, input().split())
g = math.gcd(p, q)
p //= g
q //= g
divs = [q]
for x in range(1, q):
if (q * q) % x == 0:
divs.append(x)
if x != (q * q) // x:
divs.append((q * q) // x)
ans = []
for x in divs:
y = (q * q) // x
if (x + q) % p != 0 or (y + q) % p != 0:
continue
m = (x + q) // p
n = (y + q) // p
if m > 0 and n > 0:
ans.append((m, n))
ans.sort()
print(len(ans))
for m, n in ans:
print(f"{m} {n}")