結果

問題 No.36 素数が嫌い!
ユーザー  nemunemu nemunemu
提出日時 2023-05-01 10:34:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 815 bytes
コンパイル時間 602 ms
コンパイル使用メモリ 72,144 KB
実行使用メモリ 108,780 KB
最終ジャッジ日時 2024-04-30 14:47:12
合計ジャッジ時間 7,393 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

vector<ll> getprimelst(int n) {
    vector<bool> isprime(n + 1, true);
    isprime[0] = isprime[1] = false;

    for (ll i = 2; i <= n; ++i) {
        if (!isprime[i]) continue;
        for (ll j = i * 2; j <= n; j += i) {
            isprime[j] = false;
        }
    }

    vector<ll> primelst;
    for (ll i = 2; i <= n; ++i) {
        if (isprime[i]) {
            ll tmp = n;
            while (!(tmp % i) && tmp) {
                primelst.push_back(i);
                tmp /= i;
            }
        }
    }

    return primelst;
}

int main() {
    ll N;
    cin >> N;

    vector<ll> primelst = getprimelst(N);
    if (primelst.size() > 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}
0