結果

問題 No.2751 429-like Number
ユーザー t98slidert98slider
提出日時 2024-05-16 05:36:12
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,070 ms / 4,000 ms
コード長 741 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 205,304 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-05-16 05:36:20
合計ジャッジ時間 7,026 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,812 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 3 ms
6,940 KB
testcase_04 AC 3 ms
6,940 KB
testcase_05 AC 3 ms
6,940 KB
testcase_06 AC 3 ms
6,940 KB
testcase_07 AC 6 ms
6,940 KB
testcase_08 AC 5 ms
6,940 KB
testcase_09 AC 12 ms
6,944 KB
testcase_10 AC 1,070 ms
6,940 KB
testcase_11 AC 194 ms
6,944 KB
testcase_12 AC 183 ms
6,940 KB
testcase_13 AC 127 ms
6,940 KB
testcase_14 AC 427 ms
6,940 KB
testcase_15 AC 11 ms
6,940 KB
testcase_16 AC 67 ms
6,940 KB
testcase_17 AC 84 ms
6,940 KB
testcase_18 AC 140 ms
6,944 KB
testcase_19 AC 138 ms
6,948 KB
testcase_20 AC 139 ms
6,940 KB
testcase_21 AC 135 ms
6,940 KB
testcase_22 AC 143 ms
6,944 KB
testcase_23 AC 140 ms
6,940 KB
testcase_24 AC 156 ms
6,940 KB
testcase_25 AC 139 ms
6,940 KB
testcase_26 AC 141 ms
6,940 KB
testcase_27 AC 141 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

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(100001, true);
    vector<int> p;
    p.reserve(9592);
    tb[0] = tb[1] = false;
    for(int i = 2; i <= 100000; i++){
        if(!tb[i]) continue;
        p.emplace_back(i);
        for(int j = i; j <= 100000; j += i) tb[j] = false;
    }
    
    int Q;
    cin >> Q;
    while(Q--){
        ll v;
        cin >> v;
        int cnt = 0;
        for(int i = 0; i < 9592 && 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