結果

問題 No.2125 Inverse Sum
ユーザー flygonflygon
提出日時 2022-11-19 02:11:08
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 651 bytes
コンパイル時間 227 ms
コンパイル使用メモリ 81,672 KB
実行使用メモリ 87,324 KB
最終ジャッジ日時 2023-10-20 10:31:26
合計ジャッジ時間 3,129 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

def fact(n):
  l = []
  tmp = n
  for i in range(2,int(pow(n,0.5))+1):
    if tmp % i == 0:
      cnt = 0
      while tmp % i == 0:
        cnt += 1
        tmp //= i
      l.append([i,cnt])
  if tmp != 1:
    l.append([tmp,1])
  return l


f = fact(q)
l = [1]
for i,j in f:
  tmp = l[::1]
  l = []
  for k in range(2*j+1):
    for now in tmp:
      l.append(now*pow(i, k))
qq = q*q
ans = set()
for i in l:
  j = qq//i
  i += q
  j += q
  if i % p == 0 and j % p == 0:  
    ans.add((i//p, j//p))
    ans.add((j//p,i//p))

print(len(ans))
for i, j in ans:
  print(i,j)
0