結果

問題 No.36 素数が嫌い!
ユーザー cherrypi59cherrypi59
提出日時 2018-10-01 20:21:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,711 ms / 5,000 ms
コード長 653 bytes
コンパイル時間 103 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-20 14:20:42
合計ジャッジ時間 8,743 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 423 ms
10,752 KB
testcase_01 AC 61 ms
10,752 KB
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 30 ms
10,752 KB
testcase_04 AC 30 ms
10,752 KB
testcase_05 AC 32 ms
10,752 KB
testcase_06 AC 33 ms
10,880 KB
testcase_07 AC 34 ms
10,752 KB
testcase_08 AC 29 ms
10,752 KB
testcase_09 AC 28 ms
10,752 KB
testcase_10 AC 28 ms
10,752 KB
testcase_11 AC 582 ms
10,880 KB
testcase_12 AC 1,711 ms
10,752 KB
testcase_13 AC 1,706 ms
10,752 KB
testcase_14 AC 36 ms
10,752 KB
testcase_15 AC 29 ms
10,752 KB
testcase_16 AC 28 ms
10,624 KB
testcase_17 AC 28 ms
10,752 KB
testcase_18 AC 28 ms
10,624 KB
testcase_19 AC 96 ms
10,752 KB
testcase_20 AC 82 ms
10,752 KB
testcase_21 AC 248 ms
10,752 KB
testcase_22 AC 54 ms
10,752 KB
testcase_23 AC 38 ms
10,752 KB
testcase_24 AC 268 ms
10,752 KB
testcase_25 AC 318 ms
10,624 KB
testcase_26 AC 617 ms
10,624 KB
testcase_27 AC 58 ms
10,752 KB
testcase_28 AC 605 ms
10,752 KB
testcase_29 AC 41 ms
10,752 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

fac = {}


def prime_factorization(n):
    i = 2
    while i * i <= n:
        while not n % i:
            fac[i] = fac.get(i, 0) + 1
            n //= i
        i += 1

    if n != 1:
        fac[n] = 1


def main():
    n = int(input())

    prime_factorization(n)

    if 3 <= len(fac):
        print("YES")
        exit()
    elif len(fac) == 2:
        k1, v1 = fac.popitem()
        k2, v2 = fac.popitem()
        if 1 < v1 or 1 < v2:
            print("YES")
            exit()
    elif len(fac):
        k, v = fac.popitem()
        if 2 < v:
            print("YES")
            exit()

    print("NO")


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