結果

問題 No.36 素数が嫌い!
ユーザー  nemunemu nemunemu
提出日時 2023-05-01 10:23:16
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 843 bytes
コンパイル時間 752 ms
コンパイル使用メモリ 77,204 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-30 14:41:41
合計ジャッジ時間 3,008 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

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

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

    vector<ll> primelst;
    for (ll i = 2; i * i <= n; ++i) {
        if (isprime[i]) {
            ll tmp = n;
            while (!(tmp % i)) {
                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