結果

問題 No.2379 Burnside's Theorem
ユーザー Dev KudawlaDev Kudawla
提出日時 2023-07-18 19:23:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 7,897 bytes
コンパイル時間 3,701 ms
コンパイル使用メモリ 235,692 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-18 18:41:56
合計ジャッジ時間 4,422 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 0 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 1 ms
5,376 KB
testcase_13 AC 8 ms
5,376 KB
testcase_14 AC 8 ms
5,376 KB
testcase_15 AC 11 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 AC 3 ms
5,376 KB
testcase_19 AC 1 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 1 ms
5,376 KB
testcase_22 AC 2 ms
5,376 KB
testcase_23 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// AUTHOR->DEV KUDAWLA
//----------------------------------------------------
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long, null_type, less<long long>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order(it return an iterator input is a value), order_of_key(input is index)
typedef tree<long long, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_multiset;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#define ll long long
#define vl vector<long long>
#define nline cout << "\n"
#define pb push_back
#define db pop_back
#define n_digit(n) (int)log10(n) + 1
#define msb(n) (int)(log2(n)) + 1
// it is 1 based
#define pll pair<ll, ll>
#define all(x) x.begin(), x.end()
#define lt(x) x.size()
#define ternary(a, b, c) ((a) ? (b) : (c))
#define yesno(a) a ? cout << "Yes" : cout << "No"
#define ff first
#define ss second
#define sroot(a) sqrt((long double)a)
#define Max(a, b) max((ll)a, (ll)b)
#define Min(a, b) min((ll)a, (ll)b)
#define mkp(a, b) make_pair(a, b)
#define str string
#define tbits(x) __builtin_popcountll(x)
#define LOCAL_COMPILER
#ifdef LOCAL_COMPILER
#define dbg(x)        \
   cerr << #x << " "; \
   cerr << x << "\n";
#endif
#ifndef LOCAL_COMPILER
#define dbg(x)
#endif
//----------------------------------------------------
template <class T>
istream &operator>>(istream &is, vector<T> &v)
{
   int n = v.size();
   for (int i = 0; i < n; i++)
      is >> v[i];
   return is;
}
template <class T>
istream &operator>>(istream &is, vector<vector<T>> &v)
{
   int n = v.size();
   int m = v[0].size();
   for (int i = 0; i < n; i++)
      for (int j = 0; j < m; j++)
         is >> v[i][j];
   return is;
}
template <class T>
ostream &operator<<(std::ostream &os, vector<T> &v)
{
   int n = v.size();
   for (int i = 0; i < n; i++)
      os << v[i] << ((i == n - 1) ? "\n" : " ");
   return os;
}
template <class T>
ostream &operator<<(std::ostream &os, vector<vector<T>> &v)
{
   int n = v.size();
   int m = v[0].size();
   for (int i = 0; i < n; i++)
   {
      for (int j = 0; j < m; j++)
         os << v[i][j] << " ";
      os << "\n";
   }
   return os;
}
template <class T>
vector<T> add(vector<T> v1, vector<T> v2)
{
   vector<T> v3 = v1;
   for (ll i = 0; i < v2.size(); i++)
      v3.push_back(v2[i]);
   return v3;
}
inline ll power2(ll n)
{
   ll answer = 0;
   if (n != 0)
      answer = msb(((ll)n) ^ ((ll)(n - 1))) - 1;
   return answer;
}
inline ll indexOf(ordered_multiset &st, ll value)
{
   return st.order_of_key(value);
}
inline ll valueAt(ordered_multiset &st, ll index)
{
   return *st.find_by_order(index);
}
inline ll indexOf(ordered_set &st, ll value)
{
   return st.order_of_key(value);
}
inline ll valueAt(ordered_set &st, ll index)
{
   return *st.find_by_order(index);
}
template <class T>
void Distinct(T &v, bool sorting = true)
{
   if (sorting)
      sort(begin(v), end(v));
   v.resize(unique(begin(v), end(v)) - begin(v));
}
//----------------------------------------------------
const ll N1 = 1000000007;
const ll N2 = 998244353;
const long double epsilon = 1e-9;
//----------------------------------------------------
// MODULAR ARITHMETIC
inline ll expo(ll a, ll b, ll mod = LONG_LONG_MAX)
{
   ll res = 1;
   while (b > 0)
   {
      if (b & 1)
         res = ((__int128_t)res * a) % mod;
      a = ((__int128_t)a * a) % mod;
      b = b >> 1;
   }
   return res;
}
inline ll mminvprime(ll a, ll b) { return expo(a, b - 2, b); }
inline ll mod_add(ll a, ll b, ll m = N1)
{
   a = a % m;
   b = b % m;
   return (((a + b) % m) + m) % m;
}
inline ll mod_mul(ll a, ll b, ll m = N1)
{
   a = a % m;
   b = b % m;
   return (((__int128_t)(a * b) % m) + m) % m;
}
inline ll mod_sub(ll a, ll b, ll m = N1)
{
   a = a % m;
   b = b % m;
   return (((a - b) % m) + m) % m;
}
inline ll mod_div(ll a, ll b, ll m = N1)
{
   a = a % m;
   b = b % m;
   return (mod_mul(a, mminvprime(b, m), m) + m) % m;
} // only for prime m
ll ncr(ll n, ll r, bool mod_version = false, ll mod = N1)
{
   ll answer = 0;
   if (n >= r)
   {
      r = Min(r, n - r);
      if (mod_version == true)
      {
         ll a = 1;
         for (ll i = n; i >= n - r + 1; i--)
            a = mod_mul(a, i, mod);
         ll b = 1;
         for (ll i = 1; i <= r; i++)
            b = mod_mul(b, i, mod);
         b = mminvprime(b, mod);
         a = mod_mul(a, b, mod);
         answer = a;
      }
      else
      {
         ll a = 1;
         ll b = 1;
         for (ll i = n; i >= n - r + 1; i--)
         {
            a *= i;
            b *= (n - i + 1);
            ll g = __gcd(a, b);
            a /= g, b /= g;
         }
         answer = a / b;
      }
   }
   return answer;
}
ll factorial(ll n, bool mod_version = false, ll mod = N1)
{
   ll answer = 1;
   if (mod_version == true)
   {
      for (int i = 2; i <= n; i++)
         answer = mod_mul(answer, i, mod);
   }
   else
   {
      for (int i = 2; i <= n; i++)
         answer *= i;
   }
   return answer;
}
bool is_prime(ll a)
{
   if (a == 1)
      return false;
   for (ll i = 2; i * i <= a; i++)
   {
      if (a % i == 0)
         return false;
   }
   return true;
}
//----------------------------------------------------
// KMP search
void computeLPSArray(string pat, ll M, ll lps[])
{
   ll len = 0;
   ll i = 1;
   lps[0] = 0;
   while (i < M)
   {
      if (pat[i] == pat[len])
      {
         len++;
         lps[i] = len;
         i++;
      }
      else
      {
         if (len != 0)
            len = lps[len - 1];
         else
         {
            lps[i] = len;
            i++;
         }
      }
   }
}
ll KMPSearch(string pat, string txt)
{
   ll M = pat.length();
   ll N = txt.length();
   ll lps[M];
   ll j = 0;
   computeLPSArray(pat, M, lps);
   ll i = 0;
   ll res = 0;
   ll next_i = 0;
   while (i < N)
   {
      if (pat[j] == txt[i])
         i++, j++;
      if (j == M)
      {
         j = lps[j - 1];
         res++;
      }
      else if (i < N && pat[j] != txt[i])
      {
         if (j != 0)
            j = lps[j - 1];
         else
            i = i + 1;
      }
   }
   return res;
} // O(M+N)
map<ll, ll> prime_factors(ll n, bool debug = false)
{
   map<ll, ll> answer;
   ll a = n;
   for (ll i = 2; i * i <= a; i++)
      while (a % i == 0)
         answer[i]++, a /= i;
   if (a > 1)
      answer[a]++;
   if (debug)
   {
      for (auto i : answer)
         cout << i.first << " -> " << i.second << "\n";
   }
   return answer;
}
//----------------------------------------------------
const int n_sieve = (10000000) + 1; // O(Nlog(log(N)))
// vector<bool> prime_sieve(n_sieve, true);
void initialise_sieve(vector<bool> &prime_sieve)
{
   prime_sieve[0] = false;
   prime_sieve[1] = false;
   for (ll i = 2; i * i < lt(prime_sieve); i++)
      if (prime_sieve[i] == true)
         for (ll j = 2; j * i < lt(prime_sieve); j++)
            prime_sieve[j * i] = false;
}
//----------------------------------------------------
// CODE STARTS HERE
//----------------------------------------------------
void solve(bool testCases = true)
{
   ll T = 1; //->test cases
   if (testCases)
      cin >> T;
   while (T--)
   {
      ll n;
      cin >> n;
      map<ll, ll> mp = prime_factors(n);
      yesno(mp.size() <= 2);
      nline;
      //----------------------------------------------
      //  CODE ENDS HERE
   }
}
//----------------------------------------------------
int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(NULL);
   cout.tie(NULL);
   // ------------------------------------------------
   // initialise_sieve(prime_sieve);
   //-------------------------------------------------
   solve(false);
   //-------------------------------------------------
   return 0;
}
//----------------------------------------------------
0