結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
![]() |
提出日時 | 2015-07-29 03:19:38 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 534 ms / 5,000 ms |
コード長 | 740 bytes |
コンパイル時間 | 262 ms |
コンパイル使用メモリ | 82,816 KB |
実行使用メモリ | 184,832 KB |
最終ジャッジ日時 | 2024-06-27 00:22:17 |
合計ジャッジ時間 | 8,085 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
import bisect import math def mark(s, x): for i in range(x + x, len(s), x): s[i] = False def sieve(n): s = [True] * n for x in range(2, int(n ** 0.5) + 1): if s[x]: mark(s, x) return [i for i in range(n) if s[i] and i > 1] def solve(): N = int(input()) ps = sieve(int(math.sqrt(N)) + 1) ys = [] i = 0 while i < len(ps): p = ps[i] d, m = divmod(N, p) if m == 0: ys.append(p) N = d if len(ys) >= 3: return True else: i += 1 if N > 1: ys.append(N) return len(ys) >= 3 def main(): print('YES' if solve() else 'NO') if __name__ == '__main__': main()