結果

問題 No.2751 429-like Number
ユーザー V_Melville
提出日時 2024-05-10 21:36:07
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 692 bytes
コンパイル時間 3,466 ms
コンパイル使用メモリ 247,920 KB
実行使用メモリ 13,636 KB
最終ジャッジ日時 2024-12-20 04:36:07
合計ジャッジ時間 28,822 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 21 TLE * 1
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;
using ll = long long;
using P = pair<ll, int>;

vector<P> factorize(ll n) {
    vector<P> res;
    for (ll i = 2; i*i <= n; ++i) {
        if (n%i != 0) continue;
        res.emplace_back(i, 0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}

void solve() {
    ll n;
    cin >> n;
    
    auto fs = factorize(n);
    
    int cnt = 0;
    for (auto [_, x] : fs) {
        cnt += x;
    }
    
    if (cnt == 3) puts("Yes");
    else puts("No");
}

int main() {
    int t;
    cin >> t;
    
    while (t--) solve();
    
    return 0;
}
0