結果

問題 No.2751 429-like Number
ユーザー Xinyuan HuangXinyuan Huang
提出日時 2024-10-28 18:46:02
言語 C++23(gcc13)
(gcc 13.2.0 + boost 1.83.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
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,820 KB
testcase_02 AC 3 ms
6,816 KB
testcase_03 AC 3 ms
6,820 KB
testcase_04 AC 3 ms
6,816 KB
testcase_05 AC 2 ms
6,820 KB
testcase_06 AC 5 ms
6,816 KB
testcase_07 AC 664 ms
6,820 KB
testcase_08 AC 1,044 ms
6,820 KB
testcase_09 AC 1,055 ms
6,820 KB
testcase_10 AC 1,055 ms
6,820 KB
testcase_11 AC 1,041 ms
6,816 KB
testcase_12 AC 608 ms
6,820 KB
testcase_13 AC 1,032 ms
6,816 KB
testcase_14 AC 1,009 ms
6,816 KB
testcase_15 AC 11 ms
6,816 KB
testcase_16 AC 855 ms
6,820 KB
testcase_17 AC 866 ms
6,816 KB
testcase_18 AC 601 ms
6,820 KB
testcase_19 AC 629 ms
6,816 KB
testcase_20 AC 602 ms
6,816 KB
testcase_21 AC 628 ms
6,816 KB
testcase_22 AC 614 ms
6,816 KB
testcase_23 AC 636 ms
6,820 KB
testcase_24 AC 607 ms
6,820 KB
testcase_25 AC 632 ms
6,816 KB
testcase_26 AC 602 ms
6,816 KB
testcase_27 AC 614 ms
6,816 KB
権限があれば一括ダウンロードができます

ソースコード

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