結果

問題 No.2379 Burnside's Theorem
ユーザー hari64hari64
提出日時 2023-07-14 21:26:29
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 2,024 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 208,360 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-16 06:14:10
合計ジャッジ時間 2,974 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#ifndef hari64
#include <bits/stdc++.h>
// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#define debug(...)
#else
#include "util/viewer.hpp"
#define debug(...) viewer::_debug(__LINE__, #__VA_ARGS__, __VA_ARGS__)
#endif
// clang-format off
using namespace std;
using ll = long long; using ld = long double;
using pii = pair<int, int>; using pll = pair<ll, ll>;
template <typename T> using vc = vector<T>;
template <typename T> using vvc = vector<vc<T>>;
template <typename T> using vvvc = vector<vvc<T>>;
using vi = vc<int>; using vl = vc<ll>; using vpi = vc<pii>; using vpl = vc<pll>;
#define ALL(x) begin(x), end(x)
#define RALL(x) (x).rbegin(), (x).rend()
constexpr int INF = 1001001001; constexpr long long INFll = 1001001001001001001;
template <class T> bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template <class T> bool chmin(T& a, const T& b) { return a > b ? a = b, 1 : 0; }
// clang-format on

// O(NloglogN)
vector<int> prime_table(int n) {
    assert(n >= 1);
    if (n == 1) return {};
    vector<bool> isp((n + 1) >> 1, true);
    for (int i = 3; i < int(sqrt(n)) + 1; i += 2)
        if (isp[i >> 1])
            for (int j = i * i >> 1; j < int(isp.size()); j += i) isp[j] = false;
    vector<int> ret({2});
    for (int i = 1; i < (n + 1) >> 1; i++)
        if (isp[i]) ret.push_back((i << 1) + 1);
    return ret;
}

template <class T>  // O(√N)
vector<pair<T, T>> prime_factorize(T N) {
    vector<pair<T, T>> ret;
    for (T b = 2; b * b <= N; ++b) {
        if (N % b != 0) continue;
        T e = 0;
        while (N % b == 0) {
            e++;
            N /= b;
        }
        ret.push_back({b, e});
    }
    if (N != 1) ret.push_back({N, 1});
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    auto pf = prime_factorize(N);
    debug(pf);

    if (pf.size() <= 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}
0