結果

問題 No.2125 Inverse Sum
ユーザー ntudantuda
提出日時 2022-11-22 00:14:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 526 bytes
コンパイル時間 368 ms
コンパイル使用メモリ 81,856 KB
実行使用メモリ 53,580 KB
最終ジャッジ日時 2023-10-23 19:37:30
合計ジャッジ時間 2,510 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,332 KB
testcase_01 AC 36 ms
53,332 KB
testcase_02 AC 37 ms
53,332 KB
testcase_03 AC 37 ms
53,332 KB
testcase_04 AC 37 ms
53,332 KB
testcase_05 WA -
testcase_06 AC 37 ms
53,332 KB
testcase_07 WA -
testcase_08 AC 38 ms
53,332 KB
testcase_09 AC 37 ms
53,332 KB
testcase_10 AC 38 ms
53,332 KB
testcase_11 AC 38 ms
53,332 KB
testcase_12 AC 37 ms
53,332 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 38 ms
53,332 KB
testcase_24 WA -
testcase_25 AC 37 ms
53,332 KB
testcase_26 AC 37 ms
53,332 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 37 ms
53,332 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

P, Q = map(int, input().split())
Nmin = 2 * Q // P

def check(n, m):
    return P * n * m <= Q * (n + m)

ans = []
for n in range(Nmin, Nmin + 2):
    if n == 0:
        continue
    lb = n
    ub = 10 ** 9
    while ub - lb > 1:
        mid = (ub + lb) // 2
        if check(n, mid):
            lb = mid
        else:
            ub = mid
    m = lb
    if P * n * m == Q * (n + m):
        ans.append((n, m))
        if n != m:
            ans.append((m, n))

ans.sort()
na = len(ans)
print(na)
for a in ans:
    print(*a)
0