結果

問題 No.811 約数の個数の最大化
ユーザー kamojirokamojiro
提出日時 2019-04-13 16:01:23
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 443 ms / 2,000 ms
コード長 672 bytes
コンパイル時間 569 ms
コンパイル使用メモリ 10,704 KB
実行使用メモリ 13,668 KB
最終ジャッジ日時 2023-10-13 14:22:09
合計ジャッジ時間 3,499 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,756 KB
testcase_01 AC 19 ms
7,848 KB
testcase_02 AC 394 ms
13,092 KB
testcase_03 AC 17 ms
7,788 KB
testcase_04 AC 17 ms
7,892 KB
testcase_05 AC 25 ms
8,200 KB
testcase_06 AC 47 ms
8,664 KB
testcase_07 AC 62 ms
8,780 KB
testcase_08 AC 203 ms
10,816 KB
testcase_09 AC 219 ms
11,040 KB
testcase_10 AC 148 ms
10,100 KB
testcase_11 AC 416 ms
13,144 KB
testcase_12 AC 118 ms
9,612 KB
testcase_13 AC 430 ms
13,656 KB
testcase_14 AC 443 ms
13,668 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N, K = map( int, input().split())
Ints = [ i for i in range(N)]
Primefactors = [0]*N
Factors = [1]*N
for i in range(2, N):
    if Ints[i] == 1:
        continue
    for j in range(1, N):
        if i*j < N:
            t = 1
            while Ints[i*j]%i == 0:
                Ints[i*j] //= i
                Primefactors[i*j] += 1
                t += 1
            Factors[i*j] *= t
        else:
            break
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return(a)
ans = 1
nowfactors = 1
for i in range(2,N):
    if Primefactors[gcd(i,N)] >= K:
        if Factors[i] > nowfactors:
            ans = i
            nowfactors = Factors[i]
print( ans)
0