結果

問題 No.2125 Inverse Sum
ユーザー qibqib
提出日時 2022-11-21 19:18:44
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 503 bytes
コンパイル時間 1,979 ms
コンパイル使用メモリ 81,652 KB
実行使用メモリ 68,952 KB
最終ジャッジ日時 2023-10-23 15:53:04
合計ジャッジ時間 6,395 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,704 KB
testcase_01 AC 37 ms
53,704 KB
testcase_02 AC 39 ms
53,704 KB
testcase_03 AC 39 ms
53,704 KB
testcase_04 AC 38 ms
53,704 KB
testcase_05 WA -
testcase_06 AC 41 ms
57,724 KB
testcase_07 AC 39 ms
57,724 KB
testcase_08 AC 39 ms
57,724 KB
testcase_09 AC 36 ms
53,704 KB
testcase_10 AC 41 ms
57,724 KB
testcase_11 WA -
testcase_12 AC 37 ms
53,704 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 40 ms
57,728 KB
testcase_24 AC 39 ms
57,724 KB
testcase_25 AC 39 ms
57,724 KB
testcase_26 AC 37 ms
53,704 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 37 ms
53,708 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

p, q = map(int, input().split())
g = math.gcd(p, q)
p //= g
q //= g

divs = set()
for x in range(1, int(math.sqrt(q)) + 1):
  if q % x == 0:
    y = q // x
    divs.add(x)
    divs.add((q * q) // x)
    divs.add(y)
    divs.add((q * q) // y)

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}")
0