結果

問題 No.811 約数の個数の最大化
ユーザー rlangevinrlangevin
提出日時 2023-01-19 19:42:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 328 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 276 ms
コンパイル使用メモリ 87,332 KB
実行使用メモリ 77,148 KB
最終ジャッジ日時 2023-09-04 10:01:33
合計ジャッジ時間 2,858 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,676 KB
testcase_01 AC 91 ms
76,476 KB
testcase_02 AC 81 ms
76,056 KB
testcase_03 AC 73 ms
71,852 KB
testcase_04 AC 75 ms
71,840 KB
testcase_05 AC 80 ms
76,176 KB
testcase_06 AC 74 ms
71,660 KB
testcase_07 AC 81 ms
76,072 KB
testcase_08 AC 80 ms
75,928 KB
testcase_09 AC 106 ms
76,964 KB
testcase_10 AC 86 ms
75,896 KB
testcase_11 AC 77 ms
76,328 KB
testcase_12 AC 78 ms
76,360 KB
testcase_13 AC 328 ms
77,148 KB
testcase_14 AC 78 ms
75,792 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
0