結果
| 問題 |
No.847 Divisors of Power
|
| コンテスト | |
| ユーザー |
tpyneriver
|
| 提出日時 | 2019-08-10 20:48:10 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 1,204 ms / 2,000 ms |
| コード長 | 879 bytes |
| コンパイル時間 | 308 ms |
| コンパイル使用メモリ | 82,232 KB |
| 実行使用メモリ | 125,100 KB |
| 最終ジャッジ日時 | 2024-10-07 03:13:42 |
| 合計ジャッジ時間 | 5,456 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
from heapq import heappush as hp, heappop as hpp
def prf(m):
pf = {}
for i in range(2, int(m**0.5)+1):
while m % i == 0:
pf[i] = pf.get(i, 0)+1
m //= i
if m > 1:
pf[m] = 1
return pf
def calc(Num, L):
res = 1
for n, l in zip(Num, L):
res *= pow(l, n)
return res
N, K, M = map(int, input().split())
Pf = prf(N)
if not Pf:
print(1)
else:
Pkey, Pval = map(list, zip(*Pf.items()))
pl = len(Pkey)
cnt = 0
Q = [(1, tuple(0 for _ in range(pl)))]
used = set()
while Q:
x, pp = Q.pop()
if x > M or any(a*K < b for a, b in zip(Pval, pp)) or pp in used:
continue
used.add(pp)
cnt += 1
for i in range(pl):
lp = list(pp)
lp[i] += 1
Q.append((calc(lp, Pkey), tuple(lp)))
print(cnt)
tpyneriver