結果
| 問題 |
No.2751 429-like Number
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-10 22:19:46 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 954 bytes |
| コンパイル時間 | 3,008 ms |
| コンパイル使用メモリ | 248,556 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-20 06:03:27 |
| 合計ジャッジ時間 | 9,422 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 7 WA * 15 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;
const long long INFLL = 1LL<<60;
const int MOD = 998244353;
ll q;
vector<ll> primes;
bool is_prime(ll n){
if (n < 2) return false;
for (int i = 2; i < min((ll)sqrt(n) + 5, n); i++){
if (n % i == 0) return false;
}
return true;
}
void make_primes(){
for (int i=2; i < 10000; i++){
if (is_prime(i)) primes.push_back(i);
}
}
bool is_429(ll n){
int cnt = 0;
for (int p : primes){
while (n % p == 0){
cnt++;
n /= p;
if (cnt == 2) break;
}
if (cnt == 2){
//cout << n << endl;
if (is_prime(n)) return true;
else return false;
}
}
return false;
}
int main() {
cin >> q;
make_primes();
while (q--){
ll a; cin >> a;
cout << (is_429(a) ? "Yes" : "No") << endl;
}
return 0;
}