結果

問題 No.811 約数の個数の最大化
コンテスト
ユーザー yansi819
提出日時 2024-05-12 19:17:49
言語 PyPy3
(8.0.0 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 196 ms / 2,000 ms
+ 547µs
コード長 799 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 79 ms
コンパイル使用メモリ 64,928 KB
実行使用メモリ 60,200 KB
最終ジャッジ日時 2026-10-15 01:49:03
合計ジャッジ時間 2,788 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 13
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

def prime_factors(N):
    res = []
    for i in range(2, int(N ** 0.5) + 1):
        while N % i == 0:
            res.append(i)
            N //= i
    if N != 1:
        res.append(N)
    return res

def divisors(N):
    res = 0
    for i in range(1, int(N ** 0.5) + 1):
        if N % i == 0:
            res += 1
            if i * i != N:
                res += 1
    return res

N, K = map(int, input().split())
N_pf = prime_factors(N)
#print(N, N_pf)
ma, ans = 0, -1
for M in range(N):
    i_pf = prime_factors(M)
    j = 0
    cnt = 0
    #print(M, i_pf)
    for p in i_pf:
        if j < len(N_pf) and p in N_pf[j:]:
            j = j + N_pf[j:].index(p) + 1
            cnt += 1
    if cnt >= K:
        d = divisors(M)
        if ma < d:
            ma = d
            ans = M
print(ans)
0