結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
|
提出日時 | 2022-05-16 06:49:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 111 ms / 5,000 ms |
コード長 | 1,005 bytes |
コンパイル時間 | 2,172 ms |
コンパイル使用メモリ | 200,160 KB |
最終ジャッジ日時 | 2025-01-29 08:29:22 |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define rep(i, a, b) for(ll i = (ll)a; i < (ll)b; i++) #define irep(i, v) for(auto i = (v).begin(); i != (v).end(); i++) #define ALL(v) (v).begin(), (v).end() #define SZ(v) (ll)(v).size() const ll INF = 1e18; const ld EPS = 1e-10; bool is_prime(ll n){ if(n <= 1) return false; bool res = 1; for(ll i = 2; i * i <= n; i++){ res = res && !(n % i == 0); } return res; } int main(){ cin.tie(0); ios::sync_with_stdio(false); srand((unsigned)time(NULL)); cout << fixed << setprecision(20); ll n; cin >> n; vector<ll> fac; for(ll i = 1; i * i <= n; i++){ if(n % i == 0){ fac.push_back(i); if(i * i != n) fac.push_back(n / i); } } sort(ALL(fac)); bool f = 0; rep(i, 0, SZ(fac)){ ll m = fac[i]; if(m == 1 || m == n || is_prime(m)) continue; if(n % m == 0) f = 1; } if(f) cout << "YES" << endl; else cout << "NO" << endl; return 0; }