結果

問題 No.2751 429-like Number
ユーザー t98slider
提出日時 2024-05-16 05:47:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 804 ms / 4,000 ms
コード長 826 bytes
コンパイル時間 2,168 ms
コンパイル使用メモリ 197,860 KB
最終ジャッジ日時 2025-02-21 14:16:20
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    vector<bool> tb(70923, true);
    vector<int> p;
    p.reserve(7023);
    tb[0] = tb[1] = false;
    p.push_back(2);
    for(int i = 4; i <= 70922; i += 2) tb[i] = false;
    for(int i = 3; i <= 70922; i += 2){
        if(!tb[i]) continue;
        p.emplace_back(i);
        for(int j = i, d = 2 * i; j <= 70922; j += d) tb[j] = false;
    }
    
    int Q;
    cin >> Q;
    while(Q--){
        ll v;
        cin >> v;
        int cnt = 0;
        for(int i = 0; i < 7023 && p[i] * p[i] <= v; i++){
            while(v % p[i] == 0){
                v /= p[i];
                cnt++;
            }
        }
        if(v != 1) cnt++;
        cout << (cnt == 3 ? "Yes" : "No") << '\n';
    }
}
0