結果
| 問題 |
No.847 Divisors of Power
|
| コンテスト | |
| ユーザー |
FromBooska
|
| 提出日時 | 2024-02-14 14:17:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 104 ms / 2,000 ms |
| コード長 | 922 bytes |
| コンパイル時間 | 252 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 76,876 KB |
| 最終ジャッジ日時 | 2024-09-28 18:54:27 |
| 合計ジャッジ時間 | 2,782 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 26 |
ソースコード
def factorization(n):
arr = []
temp = n
for i in range(2, int(-(-n**0.5//1))+1):
if temp%i==0:
cnt=0
while temp%i==0:
cnt+=1
temp //= i
arr.append([i, cnt])
if temp!=1:
arr.append([temp, 1])
if arr==[]:
arr.append([n, 1])
return arr
N, K, M = map(int, input().split())
N_factors = factorization(N)
NK_factors = []
for p, c in N_factors:
if p > 1:
NK_factors.append((p, c*K))
import sys
sys.setrecursionlimit(10**7)
def dfs(product, idx):
global ans
if idx == L:
if product <= M:
ans += 1
return
for i in range(NK_factors[idx][1]+1):
if product*pow(NK_factors[idx][0], i) <= M:
dfs(product*pow(NK_factors[idx][0], i), idx+1)
else: #枝刈り
break
L = len(NK_factors)
ans = 0
dfs(1, 0)
print(ans)
FromBooska