結果
| 問題 | 
                            No.1383 Numbers of Product
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-12-15 19:49:08 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 470 ms / 2,000 ms | 
| コード長 | 1,031 bytes | 
| コンパイル時間 | 283 ms | 
| コンパイル使用メモリ | 82,328 KB | 
| 実行使用メモリ | 176,216 KB | 
| 最終ジャッジ日時 | 2024-11-22 23:12:27 | 
| 合計ジャッジ時間 | 13,617 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 51 | 
ソースコード
n, k, m = map(int, input().split())
def max2(x):
    ok = 0
    ng = 10**9
    while ng - ok > 1:
        m = (ok + ng) // 2
        if m * (m + k) <= x:
            ok = m
        else:
            ng = m
    return ok
def sqrt(x):
    s = 1
    while True:
        s = (x//s+s)//2
        if s**2 <= x < (s+1)**2:
            return s
def is_2(x):
    if k < (1<<25):
        y = round(-k/2 + ((k/2)**2 + x)**0.5)
    else:
        t = k**2 + x * 4
        r = sqrt(t)
        if t != r**2:
            return False
        y = (-k + r) // 2
    return y*(y+k) == x
big2 = {}
for b in range(3, 20):
    i = 1
    while True:
        x = 1
        for j in range(b):
            x *= i + j * k
        if x > n:
            break
        if x in big2:
            big2[x] += 1
        else:
            big2[x] = 1
        i += 1
count_2 = max2(n)
for i in big2:
    if is_2(i):
        big2[i] += 1
        count_2 -= 1
ans = count_2 if m == 1 else 0
for i in big2.values():
    if i == m:
        ans += 1
print(ans)