結果

問題 No.1383 Numbers of Product
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-02-07 22:10:34
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,439 bytes
コンパイル時間 280 ms
コンパイル使用メモリ 86,720 KB
実行使用メモリ 228,184 KB
最終ジャッジ日時 2023-09-17 21:58:22
合計ジャッジ時間 48,702 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 91 ms
71,732 KB
testcase_01 AC 91 ms
71,236 KB
testcase_02 AC 92 ms
71,592 KB
testcase_03 AC 96 ms
71,460 KB
testcase_04 AC 92 ms
71,636 KB
testcase_05 AC 91 ms
71,660 KB
testcase_06 AC 92 ms
71,600 KB
testcase_07 AC 1,184 ms
162,128 KB
testcase_08 AC 1,166 ms
162,272 KB
testcase_09 AC 451 ms
195,808 KB
testcase_10 AC 1,958 ms
227,988 KB
testcase_11 AC 1,899 ms
227,760 KB
testcase_12 AC 1,935 ms
228,080 KB
testcase_13 AC 1,855 ms
227,948 KB
testcase_14 AC 1,517 ms
195,896 KB
testcase_15 AC 1,256 ms
162,352 KB
testcase_16 TLE -
testcase_17 AC 92 ms
71,488 KB
testcase_18 AC 90 ms
71,472 KB
testcase_19 AC 90 ms
71,372 KB
testcase_20 AC 91 ms
71,280 KB
testcase_21 AC 94 ms
71,420 KB
testcase_22 AC 91 ms
71,600 KB
testcase_23 AC 91 ms
71,520 KB
testcase_24 AC 93 ms
71,544 KB
testcase_25 AC 90 ms
71,320 KB
testcase_26 AC 91 ms
71,660 KB
testcase_27 AC 101 ms
76,792 KB
testcase_28 AC 107 ms
78,604 KB
testcase_29 AC 1,496 ms
195,668 KB
testcase_30 AC 1,949 ms
228,184 KB
testcase_31 AC 93 ms
71,520 KB
testcase_32 AC 179 ms
95,784 KB
testcase_33 AC 90 ms
71,372 KB
testcase_34 AC 97 ms
76,228 KB
testcase_35 AC 569 ms
210,788 KB
testcase_36 AC 1,701 ms
210,992 KB
testcase_37 AC 1,955 ms
227,924 KB
testcase_38 AC 1,980 ms
228,092 KB
testcase_39 AC 653 ms
227,832 KB
testcase_40 AC 639 ms
227,972 KB
testcase_41 AC 1,981 ms
227,976 KB
testcase_42 AC 1,968 ms
227,912 KB
testcase_43 AC 1,972 ms
227,888 KB
testcase_44 AC 653 ms
227,868 KB
testcase_45 AC 1,993 ms
228,092 KB
testcase_46 AC 93 ms
71,368 KB
testcase_47 AC 1,903 ms
227,768 KB
testcase_48 AC 1,965 ms
228,072 KB
testcase_49 AC 1,903 ms
227,736 KB
testcase_50 AC 1,954 ms
228,108 KB
testcase_51 AC 89 ms
71,172 KB
testcase_52 AC 92 ms
71,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

Aで場合分けしたい!!
AはX以下

Bはあまり大きくならない
Bに関してAを二分探索


B = 1の時
A * (A+K) がすでに多いのが嫌だ

B = 2以上の場合は
列挙可能

列挙した後、M個の奴 or M-1個のやつに関して
B=1があるかを判定すればよい
Aを二分探索すれば見つかる
M = 1の場合だけ嫌だな

別で処理する

A*(A+K)の中で、バッティングした数を覚えておく
それ以外の A*(A+K)

"""

import sys
import heapq
from collections import deque
from sys import stdin

def want(A,B):
    ret = A
    for i in range(B):
        ret *= A + (i+1)*K
    return ret

dic = {}
N,K,M = map(int,stdin.readline().split())

if M != 1:

    # B >= 2 の全列挙
    for B in range(2,22):
        for A in range(1,10**9):
            X = want(A,B)
            if X <= N:
                if X not in dic:
                    dic[X] = 1
                else:
                    dic[X] += 1
            else:
                break

    ans = 0
    #B = 1があるかを検索

    for X in dic:
        
        if M-1 <= dic[X] <= M:
            l = 0
            r = X

            while r-l != 1:
                m = (l+r)//2
                if m*(m+K) <= X:
                    l = m
                else:
                    r = m

            if l*(l+K) == X:
                dic[X] += 1

            if dic[X] == M:
                ans += 1

    print (ans)

else: #M==1の場合

    # B >= 2 の全列挙
    for B in range(2,22):
        for A in range(1,10**9):
            X = want(A,B)
            if X <= N:
                if X not in dic:
                    dic[X] = 1
                else:
                    dic[X] += 1
            else:
                break

    ans = 0
    bat = 0
    
    #B = 1があるかを検索
    #print (dic)

    for X in dic:
        
        l = 0
        r = X

        while r-l != 1:
            m = (l+r)//2
            if m*(m+K) <= X:
                l = m
            else:
                r = m

        #print (X,l,K)
        if l*(l+K) == X:
            bat += 1
            dic[X] += 1

        if dic[X] == M:
            ans += 1

    #print (ans,bat,file=sys.stderr)
    
    #有効な最大のAを求める
    l = 0
    r = 10**18
    while r-l != 1:
        m = (l+r)//2
        if m * (m+K) <= N:
            l = m
        else:
            r = m

    ans += l - bat
    print (ans)
0