結果
問題 |
No.811 約数の個数の最大化
|
ユーザー |
![]() |
提出日時 | 2020-05-01 22:30:39 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 1,033 ms / 2,000 ms |
コード長 | 706 bytes |
コンパイル時間 | 173 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,624 KB |
最終ジャッジ日時 | 2024-12-25 13:05:18 |
合計ジャッジ時間 | 3,404 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 12 |
ソースコード
N, K = map(int, input().split()) def gcd(x, y): while y: x, y = y, x % y return x def divisor(n): res = set() i = 1 while i * i <= n: if n % i == 0: res.add(i) res.add(n // i) i += 1 return sorted(res) def factorize(n): if n == 1: return [] res = [] x, y = n, 2 while y * y <= x: while x % y == 0: res.append(y) x //= y y += 1 if x > 1: res.append(x) return res maxdiv = 0 res = 0 for i in range(1, N): g = gcd(N, i) if len(factorize(g)) >= K: d = len(divisor(i)) if maxdiv < d: res = i maxdiv = d print(res)