結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
![]() |
提出日時 | 2020-06-13 21:27:23 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 802 bytes |
コンパイル時間 | 1,687 ms |
コンパイル使用メモリ | 174,956 KB |
実行使用メモリ | 72,192 KB |
最終ジャッジ日時 | 2024-06-25 21:57:05 |
合計ジャッジ時間 | 11,867 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 4 |
other | AC * 10 WA * 1 TLE * 1 -- * 14 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; } template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); ll n; cin >> n; ll max_n = 10101010; vector<bool> isprime(max_n, true); isprime[0] = isprime[1] = false; set<ll> primes; for(int i = 2; i < max_n; i++){ if(isprime[i]){ primes.insert(i); for(int j = 2 * i; j < max_n; j += i) isprime[j] = false; } } for(int i = 2; i * i <= n; i++){ if(n % i) continue; if(primes.count(i) == 0 || primes.count(n / i) == 0){ cout << "YES" << endl; exit(0); } } cout << "NO" << endl; }