結果

問題 No.2125 Inverse Sum
ユーザー LyricalMaestro
提出日時 2025-07-22 00:03:42
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 502 bytes
コンパイル時間 547 ms
コンパイル使用メモリ 82,612 KB
実行使用メモリ 59,756 KB
最終ジャッジ日時 2025-07-22 00:03:46
合計ジャッジ時間 3,678 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/2125

import math

def main():
    P, Q = map(int, input().split())

    sqrt_q = int(math.sqrt(Q))

    answers = set()
    for n in range(1, max(10, sqrt_q) + 1):
        x = Q * n
        y = P * n - Q
        if y > 0 and x % y == 0:
            z = x // y
            answers.add((n, z))
            answers.add((z, n))
    
    
    print(len(answers))
    for ans in answers:
        print(f"{ans[0]} {ans[1]}")


    



if __name__ == "__main__":
    main()
0