結果

問題 No.2177 Recurring ab
ユーザー rlangevin
提出日時 2023-01-24 00:49:32
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 46 ms / 2,000 ms
コード長 447 bytes
コンパイル時間 239 ms
コンパイル使用メモリ 82,112 KB
実行使用メモリ 60,672 KB
最終ジャッジ日時 2024-06-25 18:12:00
合計ジャッジ時間 2,053 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

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