結果
問題 |
No.811 約数の個数の最大化
|
ユーザー |
![]() |
提出日時 | 2023-01-19 19:42:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 274 ms / 2,000 ms |
コード長 | 801 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 82,336 KB |
実行使用メモリ | 75,604 KB |
最終ジャッジ日時 | 2024-06-22 09:06:04 |
合計ジャッジ時間 | 1,752 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
def factorization_num(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]) cnt = 0 for _, b in arr: cnt += b return cnt def div(n): if n <= 0: return [] S = set() i = 1 while i * i <= n: if n % i == 0: S.add(i) S.add(n // i) i += 1 return S N, K = map(int, input().split()) ans = N maxv = -1 for d in div(N): if factorization_num(d) < K: continue for v in range(d, N, d): S = div(v) if len(S) > maxv: ans = v maxv = len(S) print(ans)