結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
|
提出日時 | 2015-04-19 09:26:56 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
WA
|
実行時間 | - |
コード長 | 659 bytes |
コンパイル時間 | 185 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 86,144 KB |
最終ジャッジ日時 | 2024-07-04 17:43:04 |
合計ジャッジ時間 | 28,554 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 WA * 8 |
ソースコード
from sys import stdin from itertools import compress, count readline = stdin.readline def sieve(n): p = [1] * (n + 1) p[0] = p[1] = 0 for i in range(int(n ** 0.5) + 1): if p[i]: for j in range(2 * i, len(p), i): p[j] = 0 return p def is_dividable_nonprime(n): p = sieve(int(n ** 0.5)) cnt = 0 for i in compress(count(), p): while n % i == 0: cnt += 1 n //= i if cnt == 3: return True return False def solve(n): print('YES' if is_dividable_nonprime(n) else 'NO') def main(): n = int(readline()) solve(n) main()