結果

問題 No.2125 Inverse Sum
ユーザー pitPpitP
提出日時 2022-11-18 21:50:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 755 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 81,708 KB
実行使用メモリ 59,780 KB
最終ジャッジ日時 2023-10-20 06:38:48
合計ジャッジ時間 2,707 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,588 KB
testcase_01 AC 40 ms
53,588 KB
testcase_02 AC 39 ms
53,588 KB
testcase_03 AC 39 ms
53,588 KB
testcase_04 AC 40 ms
53,588 KB
testcase_05 WA -
testcase_06 AC 43 ms
59,632 KB
testcase_07 WA -
testcase_08 AC 40 ms
53,588 KB
testcase_09 AC 39 ms
53,588 KB
testcase_10 AC 45 ms
59,756 KB
testcase_11 AC 40 ms
53,588 KB
testcase_12 AC 39 ms
53,588 KB
testcase_13 AC 45 ms
59,768 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 45 ms
59,780 KB
testcase_17 AC 46 ms
59,780 KB
testcase_18 WA -
testcase_19 AC 48 ms
59,780 KB
testcase_20 AC 47 ms
59,768 KB
testcase_21 AC 45 ms
59,764 KB
testcase_22 WA -
testcase_23 AC 44 ms
59,760 KB
testcase_24 WA -
testcase_25 AC 40 ms
53,588 KB
testcase_26 AC 40 ms
53,588 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 40 ms
53,588 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 > 2 * q:
    print(0)
elif p == 2 * q:
    print(1)
    print(1,1)
elif p == q + 1:
    ans = set()
    ans.add((1,q))
    ans.add((q,1))
    ans = list(ans)
    ans.sort()
    print(len(ans))
    for (n,m) in ans:
        print(n,m)
elif p == q:
    print(1)
    print(2,2)
elif p < q:
    nm = []
    for n in range(1,ceil(sqrt(q))+1):
        nume = q*n
        deno = p*n-q
        if (deno > 0) and (nume % deno == 0):
            m = nume//deno
            nm.append((n,m))
    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