結果

問題 No.1383 Numbers of Product
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-02-07 22:01:51
言語 PyPy3
(7.3.15)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,445 bytes
コンパイル時間 282 ms
コンパイル使用メモリ 87,224 KB
実行使用メモリ 228,320 KB
最終ジャッジ日時 2023-09-17 21:40:28
合計ジャッジ時間 48,352 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
71,720 KB
testcase_01 AC 93 ms
71,772 KB
testcase_02 AC 92 ms
71,532 KB
testcase_03 AC 96 ms
71,672 KB
testcase_04 AC 93 ms
71,676 KB
testcase_05 AC 91 ms
71,736 KB
testcase_06 AC 93 ms
71,860 KB
testcase_07 AC 1,193 ms
162,464 KB
testcase_08 AC 1,190 ms
162,328 KB
testcase_09 AC 476 ms
195,776 KB
testcase_10 AC 1,943 ms
228,180 KB
testcase_11 AC 1,925 ms
228,280 KB
testcase_12 AC 1,931 ms
228,028 KB
testcase_13 AC 1,861 ms
228,276 KB
testcase_14 AC 1,511 ms
196,008 KB
testcase_15 AC 1,249 ms
162,304 KB
testcase_16 AC 1,903 ms
227,852 KB
testcase_17 AC 93 ms
71,528 KB
testcase_18 AC 95 ms
71,652 KB
testcase_19 AC 91 ms
71,644 KB
testcase_20 AC 93 ms
71,736 KB
testcase_21 AC 91 ms
71,864 KB
testcase_22 AC 92 ms
71,636 KB
testcase_23 AC 92 ms
71,720 KB
testcase_24 AC 91 ms
71,656 KB
testcase_25 AC 93 ms
71,632 KB
testcase_26 AC 91 ms
71,792 KB
testcase_27 AC 102 ms
76,984 KB
testcase_28 AC 108 ms
78,772 KB
testcase_29 AC 1,438 ms
195,960 KB
testcase_30 AC 1,974 ms
228,236 KB
testcase_31 AC 96 ms
71,528 KB
testcase_32 AC 186 ms
95,888 KB
testcase_33 AC 92 ms
71,648 KB
testcase_34 AC 99 ms
76,544 KB
testcase_35 AC 622 ms
211,280 KB
testcase_36 AC 1,715 ms
211,084 KB
testcase_37 AC 1,955 ms
228,204 KB
testcase_38 TLE -
testcase_39 AC 630 ms
228,012 KB
testcase_40 AC 674 ms
228,196 KB
testcase_41 AC 1,960 ms
228,296 KB
testcase_42 AC 1,909 ms
228,004 KB
testcase_43 TLE -
testcase_44 AC 621 ms
227,968 KB
testcase_45 AC 1,923 ms
228,012 KB
testcase_46 AC 97 ms
71,652 KB
testcase_47 AC 1,890 ms
227,932 KB
testcase_48 AC 1,892 ms
228,212 KB
testcase_49 AC 1,914 ms
228,320 KB
testcase_50 AC 1,914 ms
228,024 KB
testcase_51 AC 90 ms
71,724 KB
testcase_52 AC 93 ms
71,888 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+10

            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+10

        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