結果

問題 No.2751 429-like Number
ユーザー karinohito
提出日時 2024-09-12 00:13:40
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,015 ms / 4,000 ms
コード長 1,025 bytes
コンパイル時間 2,646 ms
コンパイル使用メモリ 210,096 KB
最終ジャッジ日時 2025-02-24 06:41:23
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

bool chmin(map<pair<string, string>, ll>& M, pair<string, string> P, ll x) {
    if (!M.count(P)) {
        M[P] = x;
        return 1;
    }
    else if (M[P] > x) {
        M[P] = x;
        return 1;
    }
    return 0;
}

bool is_p(string S){
    if(S=="")return 1;
    string T=S;
    reverse(T.begin(),T.end());
    return S==T;
}

int main() {

    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    vector<bool> P(1e5+1,1);
    vector<ll> PP;
    P[0]=P[1]=0;
    for(int i=0;i<1e5+1;i++)if(P[i]){
        PP.push_back(i);
        for(int j=i*2;j<=1e5;j+=i){
            P[j]=0;
        }
    }
    int q;
    cin>>q;
    for(int i=0;i<q;i++){
        ll a;
        cin>>a;
        
        int cnt=0;
        for(auto p:PP){
            while(a%p==0){
            a/=p;
            cnt++;
            if(cnt>3)break;
            }
            if(cnt>3)break;
        }
        if(a!=1)cnt++;
        cout<<(cnt==3?"Yes":"No")<<endl;
    }

}
0