結果
問題 |
No.2177 Recurring ab
|
ユーザー |
👑 ![]() |
提出日時 | 2023-01-10 01:46:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 49 ms / 2,000 ms |
コード長 | 987 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,576 KB |
実行使用メモリ | 60,928 KB |
最終ジャッジ日時 | 2024-12-20 03:23:02 |
合計ジャッジ時間 | 2,094 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 18 |
ソースコード
def General_Binary_Decrease_Search_Integer(L, R, cond, default=None): """ 条件式が単調減少であるとき, 整数上で二部探索を行う. L: 解の下限 R: 解の上限 cond: 条件 (1変数関数, 広義単調減少 を満たす) default: R で条件を満たさないときの返り値 """ if not(cond(L)): return default if cond(R): return R L-=1 while R-L>1: C=L+(R-L)//2 if cond(C): L=C else: R=C return L #================================================== def solve(): from itertools import product N=int(input()) X=0 for a,b in product(range(10), repeat=2): if a==b: continue check=lambda p:N*(a*p+b)>(p*p-1) p_max=General_Binary_Decrease_Search_Integer(max(a,b)+1, 10**9, check, 0) X+=max(p_max-max(a,b), 0) return X #================================================== print(solve())