結果
問題 | No.36 素数が嫌い! |
ユーザー | sahiya |
提出日時 | 2021-03-02 19:47:48 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 1,705 bytes |
コンパイル時間 | 1,616 ms |
コンパイル使用メモリ | 110,864 KB |
最終ジャッジ日時 | 2024-04-14 04:50:50 |
合計ジャッジ時間 | 2,423 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/string:43, from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bitset:52, from main.cpp:6: /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/allocator.h: In destructor 'std::_Rb_tree<long long int, std::pair<const long long int, long long int>, std::_Select1st<std::pair<const long long int, long long int> >, std::less<long long int>, std::allocator<std::pair<const long long int, long long int> > >::_Rb_tree_impl<std::less<long long int>, true>::~_Rb_tree_impl()': /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/allocator.h:184:7: error: inlining failed in call to 'always_inline' 'std::allocator< <template-parameter-1-1> >::~allocator() noexcept [with _Tp = std::_Rb_tree_node<std::pair<const long long int, long long int> >]': target specific option mismatch 184 | ~allocator() _GLIBCXX_NOTHROW { } | ^ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/map:62, from main.cpp:16: /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/bits/stl_tree.h:662:16: note: called from here 662 | struct _Rb_tree_impl | ^~~~~~~~~~~~~
ソースコード
#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; } /* 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 << (ans ? "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; }