結果

問題 No.811 約数の個数の最大化
ユーザー titiatitia
提出日時 2019-04-12 21:41:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 244 ms / 2,000 ms
コード長 877 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 87,016 KB
実行使用メモリ 79,388 KB
最終ジャッジ日時 2023-10-12 19:28:13
合計ジャッジ時間 2,785 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,240 KB
testcase_01 AC 110 ms
77,024 KB
testcase_02 AC 119 ms
76,820 KB
testcase_03 AC 76 ms
71,220 KB
testcase_04 AC 74 ms
71,200 KB
testcase_05 AC 92 ms
76,740 KB
testcase_06 AC 85 ms
76,244 KB
testcase_07 AC 96 ms
76,544 KB
testcase_08 AC 95 ms
76,400 KB
testcase_09 AC 132 ms
77,552 KB
testcase_10 AC 107 ms
76,820 KB
testcase_11 AC 95 ms
76,600 KB
testcase_12 AC 94 ms
76,272 KB
testcase_13 AC 244 ms
79,388 KB
testcase_14 AC 100 ms
76,436 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