結果

問題 No.2177 Recurring ab
コンテスト
ユーザー rlangevin
提出日時 2023-01-24 00:49:32
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 30 ms / 2,000 ms
コード長 447 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 263 ms
コンパイル使用メモリ 84,968 KB
実行使用メモリ 60,800 KB
最終ジャッジ日時 2026-03-12 03:42:16
合計ジャッジ時間 1,826 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def f(N, a, b, p):
    return N * (a * p + b) > p * p - 1

N = int(input())
ans = 0
for a in range(10):
    for b in range(10):
        if a == b:
            continue
        yes = 0
        no = 10 ** 9 + 1
        while no - yes != 1:
            mid = (yes + no)//2
            if f(N, a, b, mid):
                yes = mid
            else:
                no = mid
        ans += max(0, yes - max(a, b))
        # print(a, b, mid)
print(ans)
0