結果

問題 No.2125 Inverse Sum
ユーザー rlangevinrlangevin
提出日時 2023-01-28 15:37:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 559 bytes
コンパイル時間 1,602 ms
コンパイル使用メモリ 86,844 KB
実行使用メモリ 95,464 KB
最終ジャッジ日時 2023-09-11 04:34:28
合計ジャッジ時間 5,456 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,408 KB
testcase_01 AC 74 ms
71,232 KB
testcase_02 AC 73 ms
71,232 KB
testcase_03 AC 79 ms
71,236 KB
testcase_04 AC 76 ms
71,168 KB
testcase_05 WA -
testcase_06 AC 80 ms
76,276 KB
testcase_07 AC 78 ms
75,304 KB
testcase_08 AC 78 ms
75,276 KB
testcase_09 AC 82 ms
75,984 KB
testcase_10 AC 82 ms
76,252 KB
testcase_11 AC 76 ms
71,412 KB
testcase_12 AC 76 ms
71,196 KB
testcase_13 AC 78 ms
75,060 KB
testcase_14 AC 89 ms
77,728 KB
testcase_15 AC 82 ms
76,088 KB
testcase_16 AC 85 ms
76,356 KB
testcase_17 AC 76 ms
75,308 KB
testcase_18 AC 82 ms
76,040 KB
testcase_19 AC 78 ms
75,252 KB
testcase_20 AC 84 ms
76,108 KB
testcase_21 AC 78 ms
76,016 KB
testcase_22 AC 79 ms
75,832 KB
testcase_23 AC 78 ms
75,848 KB
testcase_24 AC 77 ms
75,160 KB
testcase_25 AC 76 ms
75,064 KB
testcase_26 AC 72 ms
71,092 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 77 ms
71,148 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

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

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