結果

問題 No.847 Divisors of Power
ユーザー fujitanaoki0718
提出日時 2019-07-05 23:08:54
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 746 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 17,312 KB
最終ジャッジ日時 2024-10-06 23:00:00
合計ジャッジ時間 7,402 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample -- * 4
other AC * 8 TLE * 1 -- * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections
N,K,M = [int(x) for x in input().split()]
def prime_factors(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

ps = sorted([1,*prime_factors(N)])
maxcount = {k:v*K for k,v in collections.Counter(ps).items()}

solve = set([1])

def minimum_next(solve):
    m=2**64
    for s in solve:
        for p in ps:
            if collections.Counter(prime_factors(p*s))[p]>maxcount[p]:
                continue
            if p*s not in solve:
                m=min(m,p*s)
    solve.add(m)
while(max(solve)<=M):
    minimum_next(solve)
print(len([x for x in solve if x<=M]))
0