結果
| 問題 | No.2751 429-like Number |
| コンテスト | |
| ユーザー |
arad
|
| 提出日時 | 2024-05-10 21:41:46 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,710 bytes |
| 記録 | |
| コンパイル時間 | 6,329 ms |
| コンパイル使用メモリ | 310,732 KB |
| 実行使用メモリ | 16,832 KB |
| 最終ジャッジ日時 | 2024-12-20 04:49:59 |
| 合計ジャッジ時間 | 92,368 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 5 TLE * 17 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using P = pair<ll,ll>;
using VP = vector<P>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define out(x) cout << x << endl
#define dout(x) cout << fixed << setprecision(10) << x << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)(x.size())
#define re0 return 0
#define pcnt __builtin_popcountll
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int inf = 1e9;
constexpr ll INF = 1e18;
//using mint = modint1000000007;
using mint = modint998244353;
int di[4] = {1,0,-1,0};
int dj[4] = {0,1,0,-1};
//https://drken1215.hatenablog.com/entry/2023/05/23/233000#chap5
// A^N mod M
template<class T> T pow_mod(T A, T N, T M) {
T res = 1 % M;
A %= M;
while (N) {
if (N & 1) res = (res * A) % M;
A = (A * A) % M;
N >>= 1;
}
return res;
}
bool MillerRabin(long long N, vector<long long> A) {
long long s = 0, d = N - 1;
while (d % 2 == 0) {
++s;
d >>= 1;
}
for (auto a : A) {
if (N <= a) return true;
long long t, x = pow_mod<__int128_t>(a, d, N);
if (x != 1) {
for (t = 0; t < s; ++t) {
if (x == N - 1) break;
x = __int128_t(x) * x % N;
}
if (t == s) return false;
}
}
return true;
}
bool isPrime(long long N) {
if (N <= 1) return false;
if (N == 2) return true;
if (N % 2 == 0) return false;
if (N < 4759123141LL)
return MillerRabin(N, {2, 7, 61});
else
return MillerRabin(N, {2, 325, 9375, 28178, 450775, 9780504, 1795265022});
}
int main(){
ll q;
cin >> q;
rep(qi,q){
ll a;
cin >> a;
ll cnt = 0;
for(ll i = 2;i*i*i <= a;i++){
if(!isPrime(i)) continue;
if(a%i==0){
a /= i;
cnt++;
break;
}
}
for(ll i = 2;i*i <= a;i++){
if(!isPrime(i)) continue;
if(a%i==0){
a /= i;
cnt++;
break;
}
}
if(cnt < 2){
out("No");
continue;
}
if(!isPrime(a)){
out("No");
continue;
}
out("Yes");
}
}
arad