結果

問題 No.36 素数が嫌い!
ユーザー izryt(趣味)izryt(趣味)
提出日時 2016-01-14 02:48:56
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 287 ms / 5,000 ms
コード長 714 bytes
コンパイル時間 1,684 ms
コンパイル使用メモリ 144,512 KB
実行使用メモリ 14,952 KB
最終ジャッジ日時 2023-09-09 07:30:24
合計ジャッジ時間 6,251 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 88 ms
14,648 KB
testcase_01 AC 90 ms
14,692 KB
testcase_02 AC 88 ms
14,692 KB
testcase_03 AC 88 ms
14,952 KB
testcase_04 AC 87 ms
14,748 KB
testcase_05 AC 89 ms
14,684 KB
testcase_06 AC 89 ms
14,748 KB
testcase_07 AC 89 ms
14,732 KB
testcase_08 AC 90 ms
14,668 KB
testcase_09 AC 88 ms
14,660 KB
testcase_10 AC 91 ms
14,848 KB
testcase_11 AC 121 ms
14,628 KB
testcase_12 AC 189 ms
14,684 KB
testcase_13 AC 287 ms
14,808 KB
testcase_14 AC 91 ms
14,636 KB
testcase_15 AC 90 ms
14,644 KB
testcase_16 AC 89 ms
14,848 KB
testcase_17 AC 89 ms
14,744 KB
testcase_18 AC 88 ms
14,636 KB
testcase_19 AC 89 ms
14,752 KB
testcase_20 AC 92 ms
14,680 KB
testcase_21 AC 89 ms
14,880 KB
testcase_22 AC 89 ms
14,788 KB
testcase_23 AC 89 ms
14,844 KB
testcase_24 AC 103 ms
14,704 KB
testcase_25 AC 88 ms
14,664 KB
testcase_26 AC 184 ms
14,840 KB
testcase_27 AC 176 ms
14,680 KB
testcase_28 AC 182 ms
14,680 KB
testcase_29 AC 184 ms
14,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

bool p[10000001];
bool memo[10000001];

ll n;

void sieve()
{
    for (int i = 2; i <= 10000000; ++i) {
        if (!p[i]) continue;
        for (int j = i + i; j <= 10000000; j += i) p[j] = false;
    }
}

bool is_prime(ll n)
{
    for (ll i = 2; i * i <= n; ++i) if (n % i == 0) return false;
    return true;
}

int main()
{
    cin >> n;

    memset(p, true, sizeof(p));
    sieve();

    if (n == 1 || is_prime(n)) {
        cout << "NO" << endl;
        return 0;
    }

    for (ll i = 2; i * i <= n; ++i) if (n % i == 0 && (!p[i] || !is_prime(n/i))) {
        cout << "YES" << endl;
        return 0;
    }

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