結果

問題 No.2177 Recurring ab
ユーザー lloyzlloyz
提出日時 2023-01-07 14:15:02
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 83 ms / 2,000 ms
コード長 517 bytes
コンパイル時間 861 ms
コンパイル使用メモリ 86,628 KB
実行使用メモリ 75,816 KB
最終ジャッジ日時 2023-08-21 05:08:29
合計ジャッジ時間 4,730 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
75,432 KB
testcase_01 AC 73 ms
70,868 KB
testcase_02 AC 81 ms
75,572 KB
testcase_03 AC 82 ms
75,696 KB
testcase_04 AC 81 ms
75,660 KB
testcase_05 AC 79 ms
75,364 KB
testcase_06 AC 82 ms
75,632 KB
testcase_07 AC 81 ms
75,664 KB
testcase_08 AC 80 ms
75,648 KB
testcase_09 AC 83 ms
75,404 KB
testcase_10 AC 82 ms
75,660 KB
testcase_11 AC 81 ms
75,692 KB
testcase_12 AC 80 ms
75,496 KB
testcase_13 AC 78 ms
75,532 KB
testcase_14 AC 81 ms
75,684 KB
testcase_15 AC 80 ms
75,668 KB
testcase_16 AC 81 ms
75,568 KB
testcase_17 AC 81 ms
75,500 KB
testcase_18 AC 80 ms
75,500 KB
testcase_19 AC 81 ms
75,652 KB
testcase_20 AC 81 ms
75,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())

def func(x, a, b):
    return x**2 - n * a * x - n * b - 1

ans = 0
for a in range(10):
    for b in range(10):
        if a == b:
            continue
        min_p = max(a, b) + 1
        if func(min_p, a, b) >= 0:
            continue
        left, right = min_p, 10**9 + 1
        while right - left > 1:
            mid = (left + right) // 2
            if func(mid, a, b) < 0:
                left = mid
            else:
                right = mid
        ans += left - min_p + 1
print(ans)
0