結果

問題 No.1383 Numbers of Product
ユーザー Kude
提出日時 2021-02-11 16:24:34
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,029 ms / 2,000 ms
コード長 875 bytes
コンパイル時間 310 ms
コンパイル使用メモリ 82,112 KB
実行使用メモリ 201,236 KB
最終ジャッジ日時 2024-11-22 23:27:45
合計ジャッジ時間 28,773 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import Counter
n, k, m = map(int, input().split())
c = Counter()
for s in range(1, 10 ** 6 + 1):
    now = 1
    for i in range(100):
        now *= s + i * k
        if now > n:
            break
        if i >= 2:
            c[now] += 1

def g(x):
    # a(a+k) = x
    if 1 + k > x:
        return False
    l = 1
    r = 10 ** 9
    while r - l > 1:
        c = (r + l) // 2
        if c * (c + k) <= x:
            l = c
        else:
            r = c
    return l * (l + k) == x

ans = 0
for x, cnt in c.items():
    if g(x):
        if m == 1:
            ans -= 1
        elif cnt + 1 == m:
            ans += 1
    elif cnt == m:
        ans += 1

if m == 1 and 1 + k <= n:
    l = 1
    r = 10 ** 9
    while r - l > 1:
        c = (r + l) // 2
        if c * (c + k) <= n:
            l = c
        else:
            r = c
    ans += l
print(ans)
0