結果
| 問題 | No.847 Divisors of Power |
| コンテスト | |
| ユーザー |
tpyneriver
|
| 提出日時 | 2019-08-10 20:48:10 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 786 ms / 2,000 ms |
| コード長 | 879 bytes |
| 記録 | |
| コンパイル時間 | 221 ms |
| コンパイル使用メモリ | 85,396 KB |
| 実行使用メモリ | 129,860 KB |
| 最終ジャッジ日時 | 2026-04-23 19:00:18 |
| 合計ジャッジ時間 | 3,988 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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