結果

問題 No.2125 Inverse Sum
ユーザー pitPpitP
提出日時 2022-11-18 21:45:21
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 668 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 81,772 KB
実行使用メモリ 59,800 KB
最終ジャッジ日時 2023-10-20 06:31:22
合計ジャッジ時間 2,809 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
53,632 KB
testcase_01 AC 45 ms
53,632 KB
testcase_02 AC 44 ms
53,632 KB
testcase_03 AC 45 ms
53,632 KB
testcase_04 AC 42 ms
53,632 KB
testcase_05 WA -
testcase_06 AC 45 ms
57,620 KB
testcase_07 WA -
testcase_08 AC 42 ms
53,632 KB
testcase_09 AC 41 ms
53,632 KB
testcase_10 AC 45 ms
59,796 KB
testcase_11 AC 43 ms
53,632 KB
testcase_12 AC 45 ms
53,632 KB
testcase_13 AC 46 ms
59,800 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 49 ms
59,800 KB
testcase_17 AC 46 ms
59,800 KB
testcase_18 WA -
testcase_19 AC 46 ms
59,800 KB
testcase_20 AC 48 ms
59,800 KB
testcase_21 AC 45 ms
59,800 KB
testcase_22 WA -
testcase_23 AC 44 ms
59,796 KB
testcase_24 WA -
testcase_25 AC 39 ms
53,632 KB
testcase_26 AC 40 ms
53,632 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 39 ms
53,632 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd,ceil,sqrt
p,q = map(int,input().split())
g = gcd(p,q)
p //= g
q //= g

if p/q > 2:
    print(0)
elif p//q == 2:
    print(1)
    print(1,1)
elif p == q + 1:
    ans = set()
    ans.add((1,q))
    ans.add((q,1))
    print(len(ans))
    for (n,m) in ans:
        print(n,m)
elif p == q:
    print(1)
    print(2,2)
elif p/q < 1:
    nm = []
    for n in range(1,ceil(sqrt(q))+1):
        if (p*n-q > 0) and ((q*n)%(p*n-q) == 0):
            nm.append((n,(q*n)//(p*n-q)))
    ans = set()
    for (n,m) in nm:
        ans.add((n,m))
        ans.add((m,n))
    ans = list(ans)
    ans.sort()
    print(len(ans))
    for (n,m) in ans:
        print(n,m)
0