結果
問題 | No.811 約数の個数の最大化 |
ユーザー | yomo3 |
提出日時 | 2020-06-09 12:22:49 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 276 ms / 2,000 ms |
コード長 | 905 bytes |
コンパイル時間 | 286 ms |
コンパイル使用メモリ | 87,344 KB |
実行使用メモリ | 79,664 KB |
最終ジャッジ日時 | 2023-08-30 05:29:57 |
合計ジャッジ時間 | 3,499 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
71,520 KB |
testcase_01 | AC | 85 ms
76,336 KB |
testcase_02 | AC | 202 ms
78,824 KB |
testcase_03 | AC | 72 ms
71,796 KB |
testcase_04 | AC | 75 ms
71,564 KB |
testcase_05 | AC | 96 ms
77,568 KB |
testcase_06 | AC | 145 ms
78,788 KB |
testcase_07 | AC | 115 ms
77,968 KB |
testcase_08 | AC | 198 ms
79,664 KB |
testcase_09 | AC | 132 ms
77,964 KB |
testcase_10 | AC | 133 ms
78,500 KB |
testcase_11 | AC | 132 ms
78,536 KB |
testcase_12 | AC | 144 ms
78,512 KB |
testcase_13 | AC | 276 ms
78,896 KB |
testcase_14 | AC | 189 ms
78,568 KB |
ソースコード
from math import gcd def factors(n): f = [] c = 0 while n % 2 == 0: n //= 2 c += 1 if c > 0: f.append([2, c]) p = 3 while p * p <= n: if n % p == 0: c = 0 while n % p == 0: n //= p c += 1 if c > 0: f.append([p, c]) p += 2 if n != 1: f.append([n, 1]) return f def divisors(n): divs = [] for d in range(1, int(n**0.5) + 1): if n % d == 0: divs.append(d) q = n // d if q != d: divs.append(q) return divs N, K = map(int, input().split()) ans = 0 max_ndivs = 0 for i in range(2, N): g = gcd(i, N) k = sum(f[1] for f in factors(g)) if k < K: continue ndivs = len(divisors(i)) if ndivs > max_ndivs: max_ndivs = ndivs ans = i print(ans)