結果
| 問題 | No.36 素数が嫌い! |
| コンテスト | |
| ユーザー |
AT274_
|
| 提出日時 | 2019-11-05 22:56:08 |
| 言語 | Python3 (3.14.7 + numpy 2.5.2 + scipy 1.18.0) |
| 結果 |
AC
|
| 実行時間 | 2,295 ms / 5,000 ms |
| + 479µs | |
| コード長 | 634 bytes |
| 記録 | |
| コンパイル時間 | 292 ms |
| コンパイル使用メモリ | 21,536 KB |
| 実行使用メモリ | 116,088 KB |
| 最終ジャッジ日時 | 2026-08-27 14:18:10 |
| 合計ジャッジ時間 | 26,291 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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')
AT274_