結果

問題 No.36 素数が嫌い!
ユーザー PachicobuePachicobue
提出日時 2017-07-03 03:44:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 136 ms / 5,000 ms
コード長 1,425 bytes
コンパイル時間 1,718 ms
コンパイル使用メモリ 166,488 KB
実行使用メモリ 22,576 KB
最終ジャッジ日時 2023-09-09 08:03:27
合計ジャッジ時間 7,157 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
21,496 KB
testcase_01 AC 131 ms
21,380 KB
testcase_02 AC 133 ms
21,108 KB
testcase_03 AC 129 ms
21,376 KB
testcase_04 AC 132 ms
21,196 KB
testcase_05 AC 131 ms
21,408 KB
testcase_06 AC 134 ms
21,896 KB
testcase_07 AC 135 ms
21,000 KB
testcase_08 AC 130 ms
21,776 KB
testcase_09 AC 136 ms
22,128 KB
testcase_10 AC 131 ms
21,520 KB
testcase_11 AC 126 ms
22,088 KB
testcase_12 AC 131 ms
22,196 KB
testcase_13 AC 135 ms
21,644 KB
testcase_14 AC 135 ms
21,636 KB
testcase_15 AC 132 ms
22,264 KB
testcase_16 AC 132 ms
21,940 KB
testcase_17 AC 128 ms
21,640 KB
testcase_18 AC 132 ms
21,776 KB
testcase_19 AC 127 ms
21,904 KB
testcase_20 AC 127 ms
21,364 KB
testcase_21 AC 126 ms
21,844 KB
testcase_22 AC 127 ms
22,372 KB
testcase_23 AC 127 ms
21,332 KB
testcase_24 AC 125 ms
21,288 KB
testcase_25 AC 128 ms
21,964 KB
testcase_26 AC 128 ms
21,832 KB
testcase_27 AC 127 ms
21,632 KB
testcase_28 AC 127 ms
22,576 KB
testcase_29 AC 124 ms
21,316 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define show(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v)
{
    os << "sz=" << v.size() << "\n[";
    for (const auto& p : v) {
        os << p << ",";
    }
    os << "]\n";
    return os;
}

template <typename S, typename T>
ostream& operator<<(ostream& os, const pair<S, T>& p)
{
    os << "(" << p.first << "," << p.second
       << ")";
    return os;
}


constexpr ll MOD = 1e9 + 7;

template <typename T>
constexpr T INF = numeric_limits<T>::max() / 100;

constexpr ll MAX = 1e14;
constexpr ll SQRT = 1e7;
bool isprime[SQRT];
vector<ll> prime;

int main()
{
    ll N;
    cin >> N;
    for (ll i = 0; i < SQRT; i++) {
        isprime[i] = true;
    }
    for (ll i = 2; i < SQRT; i++) {
        if (isprime[i]) {
            for (ll j = 2; i * j <= SQRT; j++) {
                isprime[i * j] = false;
            }
        }
    }
    for (ll i = 2; i < SQRT; i++) {
        if (isprime[i]) {
            prime.push_back(i);
        }
    }

    int num = 0;
    for (const ll p : prime) {
        while (N % p == 0) {
            N /= p;
            num++;
        }
    }
    if (N > 1) {
        num++;
    }

    if (num > 2) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}
0