結果

問題 No.2751 429-like Number
ユーザー Xinyuan Huang
提出日時 2024-10-28 18:46:02
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 1,055 ms / 4,000 ms
コード長 718 bytes
コンパイル時間 4,109 ms
コンパイル使用メモリ 276,548 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-28 18:46:23
合計ジャッジ時間 20,910 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 6
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
 
using i64 = long long;

constexpr int N = 1e5;

std::bitset<N + 1> st;
std::vector<int> primes;

int solve() {
    i64 n; std::cin >> n;
    int cnt = 0;
    for (auto &p: primes) {
        while (n % p == 0) {
            n /= p;
            cnt += 1;
        }
        if (cnt > 3) break;
    }
    if (n > 1) cnt += 1;
    std::cout << (cnt == 3 ? "Yes" : "No") << '\n';
    return 0;   
}

int main() {
    std::cin.tie(nullptr)->sync_with_stdio(false);
    int _; std::cin >> _;
    for (i64 i = 2; i <= N; ++i) {
        if (st[i]) continue;
        for (i64 j = i * i; j <= N; j += i)
            st[j] = 1;
        primes.push_back(i);
    }
    while (_--) solve();
    return 0;
}
0