結果

問題 No.2125 Inverse Sum
ユーザー ニックネームニックネーム
提出日時 2022-11-18 23:17:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 485 bytes
コンパイル時間 522 ms
コンパイル使用メモリ 11,832 KB
実行使用メモリ 10,220 KB
最終ジャッジ日時 2023-10-20 08:18:00
合計ジャッジ時間 3,417 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
10,220 KB
testcase_01 AC 29 ms
10,220 KB
testcase_02 AC 68 ms
10,220 KB
testcase_03 AC 68 ms
10,220 KB
testcase_04 AC 29 ms
10,220 KB
testcase_05 WA -
testcase_06 AC 46 ms
10,220 KB
testcase_07 WA -
testcase_08 AC 81 ms
10,220 KB
testcase_09 AC 67 ms
10,220 KB
testcase_10 AC 84 ms
10,220 KB
testcase_11 AC 30 ms
10,220 KB
testcase_12 AC 30 ms
10,220 KB
testcase_13 AC 41 ms
10,220 KB
testcase_14 AC 39 ms
10,220 KB
testcase_15 AC 32 ms
10,220 KB
testcase_16 AC 32 ms
10,220 KB
testcase_17 AC 35 ms
10,220 KB
testcase_18 AC 33 ms
10,220 KB
testcase_19 AC 37 ms
10,220 KB
testcase_20 AC 40 ms
10,220 KB
testcase_21 AC 39 ms
10,220 KB
testcase_22 AC 35 ms
10,220 KB
testcase_23 AC 84 ms
10,220 KB
testcase_24 WA -
testcase_25 AC 81 ms
10,220 KB
testcase_26 AC 70 ms
10,220 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 67 ms
10,220 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd
p, q = map(int, input().split())
d = gcd(p, q); p //= d; q //= d
ans = []
for n in range(1, 10**5):
    if p*n-q > 0 and n*q%(p*n-q) == 0:
        m = n*q//(p*n-q)
        if n > m: break
        ans.append((n, m))
if not ans: print(0)
elif ans[-1][0] == ans[-1][1]:
    print(len(ans)*2-1)
    for n, m in ans: print(n, m)
    for m, n in ans[-2::-1]: print(n, m)
else:
    print(len(ans)*2)
    for n, m in ans: print(n, m)
    for m, n in ans[::-1]: print(n, m)
0