結果
| 問題 | 
                            No.1383 Numbers of Product
                             | 
                    
| コンテスト | |
| ユーザー | 
                             gew1fw
                         | 
                    
| 提出日時 | 2025-06-12 15:37:08 | 
| 言語 | PyPy3  (7.3.15)  | 
                    
| 結果 | 
                             
                                MLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,219 bytes | 
| コンパイル時間 | 211 ms | 
| コンパイル使用メモリ | 82,568 KB | 
| 実行使用メモリ | 600,416 KB | 
| 最終ジャッジ日時 | 2025-06-12 15:38:09 | 
| 合計ジャッジ時間 | 3,984 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 5 MLE * 1 -- * 45 | 
ソースコード
import sys
from collections import defaultdict
def main():
    N, K, M = map(int, sys.stdin.readline().split())
    count = defaultdict(int)
    max_B = 0
    B = 1
    while True:
        # Compute minimal product for B: A=1
        product_min = 1
        valid = True
        for i in range(B + 1):
            term = 1 + i * K
            if product_min > N // term:
                valid = False
                break
            product_min *= term
            if product_min > N:
                valid = False
                break
        if not valid:
            break
        # Binary search for A_max
        low = 1
        high = 1
        while True:
            product = 1
            for i in range(B + 1):
                term = high + i * K
                if term > N or product > N // term:
                    product = N + 1
                    break
                product *= term
            if product <= N:
                high *= 2
                if high > N:
                    high = N
                    break
            else:
                break
        a_max = 0
        while low <= high:
            mid = (low + high) // 2
            product = 1
            for i in range(B + 1):
                term = mid + i * K
                if term > N or product > N // term:
                    product = N + 1
                    break
                product *= term
            if product <= N:
                a_max = mid
                low = mid + 1
            else:
                high = mid - 1
        if a_max == 0:
            B += 1
            continue
        # Iterate A from 1 to a_max and compute X
        for A in range(1, a_max + 1):
            product = 1
            for i in range(B + 1):
                term = A + i * K
                if term > N or product > N // term:
                    product = N + 1
                    break
                product *= term
            if product <= N:
                count[product] += 1
        B += 1
    # Count the X's with exactly M occurrences
    result = 0
    for x in count:
        if x <= N and count[x] == M:
            result += 1
    print(result)
if __name__ == "__main__":
    main()
            
            
            
        
            
gew1fw