結果
問題 | No.811 約数の個数の最大化 |
ユーザー | 1235486527 |
提出日時 | 2019-12-19 20:25:51 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 423 ms / 2,000 ms |
コード長 | 800 bytes |
コンパイル時間 | 85 ms |
コンパイル使用メモリ | 10,904 KB |
実行使用メモリ | 8,176 KB |
最終ジャッジ日時 | 2023-09-21 07:11:14 |
合計ジャッジ時間 | 2,092 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
7,976 KB |
testcase_01 | AC | 18 ms
8,092 KB |
testcase_02 | AC | 103 ms
8,168 KB |
testcase_03 | AC | 17 ms
7,956 KB |
testcase_04 | AC | 16 ms
7,972 KB |
testcase_05 | AC | 19 ms
8,128 KB |
testcase_06 | AC | 25 ms
8,176 KB |
testcase_07 | AC | 26 ms
8,164 KB |
testcase_08 | AC | 58 ms
7,952 KB |
testcase_09 | AC | 92 ms
8,052 KB |
testcase_10 | AC | 50 ms
8,032 KB |
testcase_11 | AC | 61 ms
8,084 KB |
testcase_12 | AC | 39 ms
8,084 KB |
testcase_13 | AC | 423 ms
8,024 KB |
testcase_14 | AC | 96 ms
7,976 KB |
ソースコード
import math def count_prime_factor(N): if N == 1: return 0 ret = 0 tmp = N c = int(math.sqrt(N)) + 1 for n in range(2, c): while tmp % n == 0: tmp = tmp // n ret += 1 if tmp == 1: break if tmp != 1: ret += 1 if ret: return ret else: return 1 def count_divisor(N): ret = 0 c = int(math.sqrt(N))+1 for i in range(1, c): if N % i == 0: ret += 1 if N != i * i: ret += 1 return ret N, K = map(int, input().split()) max_d = 0 ans = 0 for n in range(1, N): gcd = math.gcd(N, n) if count_prime_factor(gcd) >= K: d = count_divisor(n) if max_d < d: max_d = d ans = n print(ans)