結果

問題 No.811 約数の個数の最大化
ユーザー titiatitia
提出日時 2019-04-12 21:42:04
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 906 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 96 ms
コンパイル使用メモリ 11,000 KB
実行使用メモリ 9,880 KB
最終ジャッジ日時 2023-10-12 19:28:38
合計ジャッジ時間 3,038 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 17 ms
8,276 KB
testcase_01 AC 22 ms
8,212 KB
testcase_02 AC 204 ms
8,208 KB
testcase_03 AC 17 ms
8,152 KB
testcase_04 AC 17 ms
8,096 KB
testcase_05 AC 22 ms
8,092 KB
testcase_06 AC 32 ms
8,224 KB
testcase_07 AC 38 ms
8,116 KB
testcase_08 AC 103 ms
8,192 KB
testcase_09 AC 194 ms
8,444 KB
testcase_10 AC 81 ms
8,116 KB
testcase_11 AC 100 ms
8,228 KB
testcase_12 AC 66 ms
8,160 KB
testcase_13 AC 906 ms
9,880 KB
testcase_14 AC 139 ms
8,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,K=map(int,input().split())

x=N
import math 
L=int(math.sqrt(x))

FACT=dict()

for i in range(2,L+2):
    while x%i==0:
        FACT[i]=FACT.get(i,0)+1
        x=x//i

if x!=1:
    FACT[x]=FACT.get(x,0)+1

ANS=[]
for i in range(1,N):

    #素因数の個数
    j=i
    COMPRIME=0
    
    for f in FACT:
        com=FACT[f]

        com_f=0
        while j%f==0 and com_f<com:
            j//=f
            com_f+=1

        COMPRIME+=com_f

    #print(j,COMPRIME)

    if COMPRIME<K:
        continue
    ANS.append(i)


ANS2=[]
for ans in ANS:
    x=ans

    L=int(math.sqrt(x))
    FACT=dict()
    
    for i in range(2,L+2):
        while x%i==0:
            FACT[i]=FACT.get(i,0)+1
            x=x//i

    if x!=1:
        FACT[x]=FACT.get(x,0)+1

    ANSNUM=1
    for f in FACT.values():
        ANSNUM*=f+1

    ANS2.append(ANSNUM)

print(ANS[ANS2.index(max(ANS2))])
0