結果
| 問題 |
No.2751 429-like Number
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-05-10 22:15:07 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2,911 ms / 4,000 ms |
| コード長 | 929 bytes |
| コンパイル時間 | 1,643 ms |
| コンパイル使用メモリ | 194,588 KB |
| 最終ジャッジ日時 | 2025-02-21 12:53:02 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 22 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using Matrix = vector<vector<ll>>;
const int inf = 1000000000;
const ll INF = 1000000000000000000;
const ll mod = 998244353;
const ull mod_hash = (1UL << 61) - 1;
const vector<int> dx = {0, 1, 0, -1, 1, 1, -1, -1};
const vector<int> dy = {1, 0, -1, 0, 1, -1, 1, -1};
int prime(ll x) {
int res = 0;
while (x % 2 == 0) {
res++;
x /= 2;
}
while (x % 3 == 0) {
res++;
x /= 3;
}
for (ll i = 1; (6 * i - 1) * (6 * i - 1) <= x; i++) {
while (x % (6 * i - 1) == 0) {
res++;
x /= (6 * i - 1);
}
while (x % (6 * i + 1) == 0) {
res++;
x /= (6 * i + 1);
}
}
if (x != 1) {
res++;
}
return res;
}
int main(){
int Q;cin>>Q;
while(Q--){
ll a;cin>>a;
if(prime(a) ==3){
cout<<"Yes"<<endl;
}else{
cout<<"No"<<endl;
}
}
return 0;
}