結果

問題 No.2125 Inverse Sum
ユーザー pitPpitP
提出日時 2022-11-19 02:06:32
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 81,652 KB
実行使用メモリ 61,640 KB
最終ジャッジ日時 2023-10-20 10:28:03
合計ジャッジ時間 4,264 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
58,004 KB
testcase_01 AC 38 ms
53,656 KB
testcase_02 AC 38 ms
53,656 KB
testcase_03 AC 38 ms
53,656 KB
testcase_04 AC 37 ms
53,656 KB
testcase_05 WA -
testcase_06 AC 38 ms
53,656 KB
testcase_07 TLE -
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 #

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