結果

問題 No.2125 Inverse Sum
ユーザー rlangevinrlangevin
提出日時 2023-01-28 15:41:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 336 ms / 2,000 ms
コード長 570 bytes
コンパイル時間 544 ms
コンパイル使用メモリ 86,608 KB
実行使用メモリ 94,456 KB
最終ジャッジ日時 2023-09-11 04:36:50
合計ジャッジ時間 5,857 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,140 KB
testcase_01 AC 73 ms
71,264 KB
testcase_02 AC 76 ms
71,132 KB
testcase_03 AC 77 ms
71,372 KB
testcase_04 AC 77 ms
71,132 KB
testcase_05 AC 84 ms
76,056 KB
testcase_06 AC 81 ms
75,880 KB
testcase_07 AC 78 ms
75,312 KB
testcase_08 AC 77 ms
75,192 KB
testcase_09 AC 82 ms
76,252 KB
testcase_10 AC 82 ms
76,020 KB
testcase_11 AC 77 ms
71,236 KB
testcase_12 AC 77 ms
71,264 KB
testcase_13 AC 79 ms
75,372 KB
testcase_14 AC 91 ms
77,300 KB
testcase_15 AC 86 ms
76,128 KB
testcase_16 AC 86 ms
76,108 KB
testcase_17 AC 81 ms
75,132 KB
testcase_18 AC 82 ms
76,024 KB
testcase_19 AC 80 ms
75,368 KB
testcase_20 AC 88 ms
76,160 KB
testcase_21 AC 82 ms
76,036 KB
testcase_22 AC 86 ms
76,120 KB
testcase_23 AC 84 ms
76,008 KB
testcase_24 AC 81 ms
75,308 KB
testcase_25 AC 80 ms
75,600 KB
testcase_26 AC 76 ms
71,192 KB
testcase_27 AC 336 ms
94,456 KB
testcase_28 AC 298 ms
90,164 KB
testcase_29 AC 223 ms
91,752 KB
testcase_30 AC 77 ms
71,320 KB
testcase_31 AC 301 ms
90,384 KB
testcase_32 AC 203 ms
87,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def div(n):
    S = set()
    i = 1
    while i * i <= n:
        if n % i == 0:
            S.add(i)
            S.add(n // i)
        i += 1
    S.add(1)
    return list(S)

P, Q = map(int, input().split())
S = set()
L = div(Q)
for a in L:
    for b in L:
        S.add(a * b)
        S.add(-a * b)
    
ans = []
Q2 = Q * Q
for d1 in S:
    d2 = Q2 // d1
    if (d1 + Q) <= 0 or (d2 + Q) <= 0:
        continue
    if (d1 + Q) % P or (d2 + Q) % P:
        continue
    ans.append(((d1 + Q)//P, (d2 + Q)//P))

ans.sort()
print(len(ans))
for a, b in ans:
    print(a, b)
0