結果

問題 No.811 約数の個数の最大化
ユーザー ああいいああいい
提出日時 2022-03-01 00:19:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 323 ms / 2,000 ms
コード長 774 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,064 KB
実行使用メモリ 112,296 KB
最終ジャッジ日時 2023-09-21 09:17:05
合計ジャッジ時間 4,305 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
71,628 KB
testcase_01 AC 123 ms
77,660 KB
testcase_02 AC 300 ms
110,332 KB
testcase_03 AC 97 ms
71,820 KB
testcase_04 AC 106 ms
77,656 KB
testcase_05 AC 132 ms
78,724 KB
testcase_06 AC 145 ms
78,456 KB
testcase_07 AC 160 ms
82,772 KB
testcase_08 AC 204 ms
91,976 KB
testcase_09 AC 213 ms
92,756 KB
testcase_10 AC 186 ms
90,092 KB
testcase_11 AC 290 ms
109,248 KB
testcase_12 AC 177 ms
87,612 KB
testcase_13 AC 323 ms
112,296 KB
testcase_14 AC 300 ms
112,016 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K = map(int,input().split())
dat = [0] * (N + 1)
from collections import defaultdict
d = [defaultdict(int) for _ in range(N+1)]
n = N
for i in range(2,N+1):
    if dat[i] == 0:
        for j in range(i,N+1,i):
            dat[j] = 1
        u = i
        count = 0
        while n % i == 0:
            count += 1
            n //= i

        c = 1
        while u <= N:
            for j in range(u,N+1,u):
                d[j][i] += 1
                if c <= count:
                    d[j][-1] += 1
            c += 1
            u *= i
M = 0
div = 0
for i in range(2,N):
    if d[i][-1] >= K:
        tmp = 1
        for k in d[i]:
            if k == -1:continue
            tmp *= (d[i][k] + 1)
        if tmp > div:
            div = tmp
            M = i
print(M)
0