結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
|
提出日時 | 2018-11-19 22:20:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 617 bytes |
コンパイル時間 | 632 ms |
コンパイル使用メモリ | 81,264 KB |
最終ジャッジ日時 | 2025-01-06 16:54:20 |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 16 WA * 10 |
ソースコード
#include<iostream> #include<vector> #include<map> #include<algorithm> #include<bitset> static int const MAX = 10000000 + 1; std::vector<int> primes() { std::vector<int> rs; std::bitset<MAX> ps; ps.set(); ps[0] = ps[1] = 0; for(int i{2}; i < MAX; ++i) { if(!ps[i]) continue; rs.push_back(i); for(int j{i * 2}; j < MAX; j += i) { ps[j] = 0; } } return rs; } int main(int, char**) { long long n; std::cin >> n; auto ps = primes(); for(auto e: ps) { if(n % e == 0) { std::cout << "YES" << std::endl; return 0; } } std::cout << "NO" << std::endl; }