結果

問題 No.2125 Inverse Sum
ユーザー qibqib
提出日時 2022-11-21 19:12:26
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 463 bytes
コンパイル時間 306 ms
コンパイル使用メモリ 81,816 KB
実行使用メモリ 64,032 KB
最終ジャッジ日時 2023-10-23 15:04:34
合計ジャッジ時間 4,593 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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