結果

問題 No.36 素数が嫌い!
ユーザー troro_kelptroro_kelp
提出日時 2019-01-03 14:42:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,771 bytes
コンパイル時間 785 ms
コンパイル使用メモリ 96,632 KB
実行使用メモリ 13,356 KB
最終ジャッジ日時 2023-08-15 14:12:44
合計ジャッジ時間 8,333 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
13,356 KB
testcase_01 AC 52 ms
13,096 KB
testcase_02 AC 50 ms
13,156 KB
testcase_03 AC 50 ms
13,124 KB
testcase_04 AC 52 ms
13,072 KB
testcase_05 AC 51 ms
13,168 KB
testcase_06 AC 52 ms
13,124 KB
testcase_07 AC 53 ms
13,284 KB
testcase_08 AC 52 ms
13,132 KB
testcase_09 AC 52 ms
13,056 KB
testcase_10 AC 52 ms
13,084 KB
testcase_11 TLE -
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 <string>
#include <vector>
#include <set>
#include <cmath>
#include <stack>
#include <algorithm>
#include <iomanip>
#include <map>
#include <queue>
#include <functional>
#include <numeric>
#include <chrono>
using ll = long long;
using namespace std;

const ll MOD = 1e9 + 7;
#define REP(i, n) for (int(i) = 0; (i) < (n); ++(i))
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
// bool operator<(const pair<int, int> &a, const pair<int, int> &b)
// {
//     if (a.first == b.first)
//         return a.second < b.second;
//     return a.first < b.first;
// };

/*unsigned int xor128(void)
{
    static unsigned int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned int t = (x ^ (x << 11));
    x = y;
    y = z;
    z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
unsigned int xor128rnd(unsigned int m)
{
    return xor128() % m;
}*/

bool sieve[10000010];

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

    if (N == 1)
    {
        cout << "NO" << endl;
        return 0;
    }
    REP(i, 10000010)
    {
        sieve[i] = true;
    }

    sieve[0] = sieve[1] = false;
    for (int i = 2; i * i < 10000010; ++i)
    {
        if (sieve[i])
        {
            for (int j = 2; i * j < 10000010; ++j)
            {
                sieve[i * j] = false;
            }
        }
    }

    int divp = 0;

    for (int i = 2; i * i <= N; ++i)
    {
        if (N % i == 0)
        {
            if (sieve[i])
                divp++;
            else
            {
                cout << "YES" << endl;
                return 0;
            }
        }

        if (divp == 2)
        {
            cout << "YES" << endl;
            return 0;
        }
    }

    cout << "NO" << endl;
    return 0;
}
0