結果
問題 | No.36 素数が嫌い! |
ユーザー |
![]() |
提出日時 | 2019-11-05 22:56:08 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 3,534 ms / 5,000 ms |
コード長 | 634 bytes |
コンパイル時間 | 321 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 111,488 KB |
最終ジャッジ日時 | 2024-09-15 00:14:56 |
合計ジャッジ時間 | 34,610 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
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')