結果
問題 | No.36 素数が嫌い! |
ユーザー |
![]() |
提出日時 | 2020-06-13 21:48:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 308 ms / 5,000 ms |
コード長 | 795 bytes |
コンパイル時間 | 1,837 ms |
コンパイル使用メモリ | 172,816 KB |
実行使用メモリ | 36,096 KB |
最終ジャッジ日時 | 2024-06-25 22:36:04 |
合計ジャッジ時間 | 11,799 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#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; } } int cnt = 0; for(ll p : primes){ while(n % p == 0){ n /= p; cnt++; } } if(n > 1) cnt++; if(cnt > 2){ cout << "YES" << endl; }else{ cout << "NO" << endl; } }