結果
| 問題 |
No.811 約数の個数の最大化
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-02-02 17:28:47 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 603 ms / 2,000 ms |
| コード長 | 758 bytes |
| コンパイル時間 | 125 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 43,648 KB |
| 最終ジャッジ日時 | 2024-09-18 21:17:27 |
| 合計ジャッジ時間 | 4,432 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from collections import defaultdict
from operator import mul
from functools import reduce
N,K = map(int,read().split())
factor = [defaultdict(int) for _ in range(N+1)]
for p in range(2,N+1):
if factor[p]:
continue
q = p
while q <= N:
for i in range(q,N+1,q):
factor[i][p] += 1
q *= p
fN = factor[N]
pN = fN.keys()
best = 0
answer = 0
for n in range(2,N):
f = factor[n]
common = sum(min(f[p], fN[p]) for p in pN)
if common < K:
continue
div_cnt = reduce(mul, (x+1 for x in f.values()))
if div_cnt > best:
best = div_cnt
answer = n
print(answer)
maspy