結果

問題 No.2177 Recurring ab
ユーザー 👑 KazunKazun
提出日時 2023-01-06 21:53:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 1,140 bytes
コンパイル時間 1,051 ms
コンパイル使用メモリ 86,856 KB
実行使用メモリ 75,740 KB
最終ジャッジ日時 2023-08-20 14:58:54
合計ジャッジ時間 2,692 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
75,396 KB
testcase_01 AC 68 ms
75,252 KB
testcase_02 AC 70 ms
75,584 KB
testcase_03 AC 67 ms
75,376 KB
testcase_04 AC 69 ms
75,524 KB
testcase_05 AC 68 ms
75,452 KB
testcase_06 AC 68 ms
75,664 KB
testcase_07 AC 69 ms
75,604 KB
testcase_08 AC 72 ms
75,588 KB
testcase_09 AC 70 ms
75,740 KB
testcase_10 AC 70 ms
75,680 KB
testcase_11 AC 70 ms
75,576 KB
testcase_12 AC 69 ms
75,352 KB
testcase_13 AC 67 ms
75,460 KB
testcase_14 AC 71 ms
75,696 KB
testcase_15 AC 68 ms
75,660 KB
testcase_16 AC 70 ms
75,608 KB
testcase_17 AC 70 ms
75,644 KB
testcase_18 AC 71 ms
75,580 KB
testcase_19 AC 70 ms
75,584 KB
testcase_20 AC 70 ms
75,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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():
    N=int(input())

    X=0

    # 2<=p<=9
    for p in range(2,10):
        for a in range(p):
            for b in range(p):
                if a!=b and N*(a*p+b)>(p*p-1):
                    X+=1

    # 10<=p
    for a in range(10):
        for b in range(10):
            if a==b:
                continue

            check=lambda p:N*(a*p+b)>(p*p-1)
            p_max=General_Binary_Decrease_Search_Integer(1,10**9,check)
            X+=max(p_max-9,0)
    return X
#==================================================
print(solve())
0