結果

問題 No.2751 429-like Number
ユーザー aaaaaaaaaa2230aaaaaaaaaa2230
提出日時 2024-05-10 22:58:13
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,026 ms / 4,000 ms
コード長 911 bytes
コンパイル時間 2,842 ms
コンパイル使用メモリ 251,636 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-05-10 22:58:39
合計ジャッジ時間 24,140 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 4 ms
6,940 KB
testcase_03 AC 3 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 5 ms
6,940 KB
testcase_07 AC 977 ms
6,940 KB
testcase_08 AC 969 ms
6,940 KB
testcase_09 AC 967 ms
6,940 KB
testcase_10 AC 975 ms
6,944 KB
testcase_11 AC 958 ms
6,944 KB
testcase_12 AC 978 ms
6,944 KB
testcase_13 AC 968 ms
6,944 KB
testcase_14 AC 946 ms
6,940 KB
testcase_15 AC 959 ms
6,944 KB
testcase_16 AC 986 ms
6,940 KB
testcase_17 AC 969 ms
6,944 KB
testcase_18 AC 978 ms
6,944 KB
testcase_19 AC 971 ms
6,940 KB
testcase_20 AC 941 ms
6,940 KB
testcase_21 AC 1,026 ms
6,940 KB
testcase_22 AC 955 ms
6,940 KB
testcase_23 AC 974 ms
6,944 KB
testcase_24 AC 942 ms
6,944 KB
testcase_25 AC 974 ms
6,940 KB
testcase_26 AC 996 ms
6,944 KB
testcase_27 AC 961 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);


    int M = 100005;
    vector<int> isPrime(M);
    vector<int> prime;
    for (int i = 2; i < M; i++){
        if (isPrime[i]) continue;
        prime.push_back(i);
        for (int j = i; j < M; j+= i){
            isPrime[j] = 1;
        }
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++){
        long long a;
        cin >> a;
        vector<long long> facts;
        bool ok = true;
        for (auto p : prime){
            if (a%p) continue;
            while (a%p == 0){
                facts.push_back(p);
                a /= p;
            }
           
        }
        if (a != 1) facts.push_back(a);
        if (ok && facts.size() == 3){
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

    

    return 0;
}
0