結果

問題 No.2125 Inverse Sum
ユーザー ああいいああいい
提出日時 2022-11-29 15:13:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 751 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 60,680 KB
最終ジャッジ日時 2024-04-16 09:55:23
合計ジャッジ時間 2,906 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,480 KB
testcase_01 AC 39 ms
52,480 KB
testcase_02 AC 39 ms
51,840 KB
testcase_03 AC 39 ms
52,224 KB
testcase_04 AC 39 ms
51,712 KB
testcase_05 WA -
testcase_06 AC 46 ms
58,112 KB
testcase_07 WA -
testcase_08 AC 40 ms
52,480 KB
testcase_09 AC 40 ms
52,224 KB
testcase_10 AC 43 ms
57,344 KB
testcase_11 AC 40 ms
51,968 KB
testcase_12 AC 40 ms
52,456 KB
testcase_13 AC 43 ms
57,856 KB
testcase_14 AC 43 ms
57,984 KB
testcase_15 AC 45 ms
57,984 KB
testcase_16 AC 43 ms
57,984 KB
testcase_17 AC 43 ms
57,984 KB
testcase_18 AC 43 ms
57,984 KB
testcase_19 AC 43 ms
58,240 KB
testcase_20 AC 43 ms
57,600 KB
testcase_21 AC 45 ms
57,728 KB
testcase_22 AC 44 ms
57,344 KB
testcase_23 AC 43 ms
57,472 KB
testcase_24 WA -
testcase_25 AC 41 ms
51,840 KB
testcase_26 AC 39 ms
51,712 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

P,Q = map(int,input().split())
import sys
if P == Q + Q:
    print(1)
    print(2,2)
    exit()
if P > Q + Q:
    print(0)
    exit()
if P == Q:
    print(1)
    print(2,2)
    exit()
if P > Q:
    P -= Q
    if Q % P == 0:
        print(2)
        print(1,Q // P)
        print(Q // P,1)
        exit()
    else:
        print(0)
        exit()
ans = []
inf = 10 ** 5
q = 1
while q * q <= Q:
    if Q % q == 0:
        r = Q // q
        a = q * P - Q
        b = Q * q
        if a > 0 and b % a == 0:
            ans.append((q,b // a))
        if r != q:
            a = r * P - Q
            b = Q * r
            if a > 0 and b % a == 0:
                ans.append((r,b // a))
    q += 1
ans.sort()
print(len(ans))
for a,b in ans:
    print(a,b)
0