結果
問題 |
No.36 素数が嫌い!
|
ユーザー |
![]() |
提出日時 | 2021-03-02 19:50:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 106 ms / 5,000 ms |
コード長 | 1,810 bytes |
コンパイル時間 | 1,662 ms |
コンパイル使用メモリ | 119,452 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-15 00:20:35 |
合計ジャッジ時間 | 3,020 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 26 |
ソースコード
#pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include <algorithm> #include <bitset> #include <climits> #include <cmath> #include <cstring> #include <deque> #include <forward_list> #include <functional> #include <iomanip> #include <iostream> #include <list> #include <map> #include <queue> #include <set> #include <string> #include <unordered_map> #include <unordered_set> #include <utility> #include <vector> using namespace std; typedef long long ll; typedef pair<int, int> P; typedef bitset<16> BS; struct edge { int to, cost, id; }; const double EPS = 1E-09; const ll MOD = 1E+09 + 7; // =998244353; const ll INF = 1E18; const int MAX_N = 1E+05; ll dx[4] = { -1, 1, 0, 0 }, dy[4] = { 0, 0, -1, 1 }; ll N; map<ll, ll> prime_factor(ll n); int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cin >> N; auto res = prime_factor(N); // bool ans = true; // if (res.size() == 2) { // ans = !all_of(res.begin(), res.end(), [](pair<ll, ll> p) { return p.second == 1; }); // } else if (res.size() == 1) { // if (res.begin()->second <= 2) // ans = false; // } else if (res.size() == 0) { // ans = false; // } ll cnt = 0; for (auto p : res) { cnt += p.second; } /* for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n"; } } */ cout << (cnt >= 3 ? "YES" : "NO") << "\n"; return 0; } //素因数分解 map<ll, ll> prime_factor(ll n) { map<ll, ll> mp; for (ll i = 2; i * i <= n; i++) { while (n % i == 0) { mp[i]++; n /= i; } } if (n != 1) mp[n] = 1; return mp; }