結果

問題 No.36 素数が嫌い!
ユーザー izryt(趣味)izryt(趣味)
提出日時 2016-01-14 02:40:33
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 727 bytes
コンパイル時間 2,087 ms
コンパイル使用メモリ 159,208 KB
実行使用メモリ 14,332 KB
最終ジャッジ日時 2023-10-19 23:02:29
合計ジャッジ時間 9,597 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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 ((!p[i] && n % i == 0) || (!p[n/i] && n % (n/i) == 0)) {
        cout << "YES" << endl;
        return 0;
    }

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