結果

問題 No.36 素数が嫌い!
ユーザー AT274_AT274_
提出日時 2019-11-05 22:56:08
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,759 ms / 5,000 ms
コード長 634 bytes
コンパイル時間 88 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 109,044 KB
最終ジャッジ日時 2023-10-13 02:31:04
合計ジャッジ時間 27,716 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 905 ms
55,564 KB
testcase_01 AC 1,590 ms
87,304 KB
testcase_02 AC 16 ms
8,532 KB
testcase_03 AC 16 ms
8,368 KB
testcase_04 AC 17 ms
8,408 KB
testcase_05 AC 21 ms
8,872 KB
testcase_06 AC 23 ms
8,748 KB
testcase_07 AC 22 ms
8,792 KB
testcase_08 AC 17 ms
8,464 KB
testcase_09 AC 19 ms
8,596 KB
testcase_10 AC 18 ms
8,540 KB
testcase_11 AC 849 ms
41,860 KB
testcase_12 AC 2,698 ms
109,044 KB
testcase_13 AC 2,759 ms
108,872 KB
testcase_14 AC 1,245 ms
71,224 KB
testcase_15 AC 15 ms
7,928 KB
testcase_16 AC 15 ms
8,368 KB
testcase_17 AC 16 ms
8,388 KB
testcase_18 AC 17 ms
7,824 KB
testcase_19 AC 749 ms
48,220 KB
testcase_20 AC 2,006 ms
108,888 KB
testcase_21 AC 1,505 ms
85,736 KB
testcase_22 AC 1,541 ms
88,096 KB
testcase_23 AC 911 ms
56,572 KB
testcase_24 AC 1,130 ms
61,972 KB
testcase_25 AC 1,006 ms
61,068 KB
testcase_26 AC 1,397 ms
69,956 KB
testcase_27 AC 1,607 ms
95,052 KB
testcase_28 AC 1,361 ms
68,716 KB
testcase_29 AC 1,772 ms
105,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())


def eratosthenes_sieve(n):
    if n < 2:
        return []

    is_primes = [True] * (n + 1)
    for x in range(2, int(n ** 0.5 + 1) + 1):
        if is_primes[x]:
            for mx in range(2 * x, n + 1, x):
                is_primes[mx] = False

    return [i for i in range(2, n + 1) if is_primes[i]]


def is_prime(n):
    for x in range(2, int(n ** 0.5) + 1):
        if n % x == 0:
            return False
    return True


Primes = set(eratosthenes_sieve(int(N ** 0.5) + 2))
Primes.add(1)
for p in Primes:
    if (N % p == 0) and is_prime(N // p):
        print('NO')
        exit()
else:
    print('YES')
0