結果

問題 No.811 約数の個数の最大化
ユーザー kamojirokamojiro
提出日時 2019-04-12 22:46:02
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 1,215 bytes
コンパイル時間 116 ms
コンパイル使用メモリ 11,024 KB
実行使用メモリ 9,404 KB
最終ジャッジ日時 2023-10-12 22:43:32
合計ジャッジ時間 2,619 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
9,248 KB
testcase_01 AC 93 ms
9,272 KB
testcase_02 AC 94 ms
9,380 KB
testcase_03 AC 93 ms
9,328 KB
testcase_04 AC 92 ms
9,304 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 92 ms
9,220 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 93 ms
9,216 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
import heapq
h = []
Prime = [1 for i in range(10**5+1)]
Prime[0] = Prime[1] = 0
for i in range(2,10**5+1):
    if Prime[i] == 1:
        for j in range(2, 10**5):
            if i*j <= 10**5:
                Prime[i*j] = 0
            else:
                break

D = defaultdict( int)
N, K = map( int, input().split())
A = []
now = N
for i in range(2, 10**5):
    if now == 1:
        break
    while now%i == 0:
        now //= i
        A.append(i)
        D[i] += 1
def check(d):
    ret = 0
    for f in d:
        ret += d[f]
    return(ret)
ans = 1
E = defaultdict( int)
while check(E) < K:
    for f in D:
        if D[f] >= 1:
            E[f] += 1
            D[f] -= 1

        if check(E) >= K:
            break
for f in E:
    ans *= f**E[f]
t = 2
for i in range(10**5+1):
    if Prime[i] == 1:
        if E[i] == 0:
            if ans*i < N:
                ans *= i
            else:
                break
for i in range(1,17):
    for j in range(2, 10**5+1):
        if Prime[j] == 1:
            if E[j] <= i:
                if ans*j < N:
                    ans *= j
                else:
                    break
    if ans*2 >= N:
        break
print( ans)
0