結果

問題 No.811 約数の個数の最大化
ユーザー tails1434tails1434
提出日時 2020-01-08 07:39:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 188 ms / 2,000 ms
コード長 757 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-05-02 12:26:56
合計ジャッジ時間 2,016 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,608 KB
testcase_01 AC 55 ms
62,464 KB
testcase_02 AC 108 ms
76,288 KB
testcase_03 AC 38 ms
52,224 KB
testcase_04 AC 38 ms
52,864 KB
testcase_05 AC 53 ms
64,384 KB
testcase_06 AC 73 ms
71,936 KB
testcase_07 AC 71 ms
71,040 KB
testcase_08 AC 93 ms
76,672 KB
testcase_09 AC 96 ms
76,288 KB
testcase_10 AC 93 ms
76,288 KB
testcase_11 AC 69 ms
66,688 KB
testcase_12 AC 83 ms
76,416 KB
testcase_13 AC 188 ms
76,288 KB
testcase_14 AC 101 ms
76,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from math import gcd

def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return len(ass)

def divisor(n):
    ass = []
    for i in range(1,int(n**0.5)+1):
        if n%i == 0:
            ass.append(i)
            if i**2 == n:
                continue
            ass.append(n//i)
    return len(ass)

def main():
    N, K = map(int, input().split())
    cnt = 0
    ans = 0
    for i in range(1, N):
        max_div = gcd(i, N)
        if prime_factor(max_div) >= K:
            d = divisor(i)
            if cnt < d:
                cnt = d
                ans = i

    print(ans)



if __name__ == "__main__":
    main()
0