結果
| 問題 |
No.811 約数の個数の最大化
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-12 19:17:49 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 692 ms / 2,000 ms |
| コード長 | 799 bytes |
| コンパイル時間 | 408 ms |
| コンパイル使用メモリ | 82,432 KB |
| 実行使用メモリ | 77,452 KB |
| 最終ジャッジ日時 | 2024-12-20 09:13:00 |
| 合計ジャッジ時間 | 4,466 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 |
ソースコード
def prime_factors(N):
res = []
for i in range(2, int(N ** 0.5) + 1):
while N % i == 0:
res.append(i)
N //= i
if N != 1:
res.append(N)
return res
def divisors(N):
res = 0
for i in range(1, int(N ** 0.5) + 1):
if N % i == 0:
res += 1
if i * i != N:
res += 1
return res
N, K = map(int, input().split())
N_pf = prime_factors(N)
#print(N, N_pf)
ma, ans = 0, -1
for M in range(N):
i_pf = prime_factors(M)
j = 0
cnt = 0
#print(M, i_pf)
for p in i_pf:
if j < len(N_pf) and p in N_pf[j:]:
j = j + N_pf[j:].index(p) + 1
cnt += 1
if cnt >= K:
d = divisors(M)
if ma < d:
ma = d
ans = M
print(ans)