結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 92 ms
13,052 KB
testcase_01 AC 94 ms
13,052 KB
testcase_02 AC 92 ms
13,096 KB
testcase_03 AC 92 ms
13,264 KB
testcase_04 AC 92 ms
13,112 KB
testcase_05 AC 92 ms
13,148 KB
testcase_06 AC 93 ms
13,048 KB
testcase_07 AC 92 ms
13,064 KB
testcase_08 AC 92 ms
13,140 KB
testcase_09 AC 92 ms
13,148 KB
testcase_10 AC 93 ms
13,052 KB
testcase_11 AC 124 ms
13,092 KB
testcase_12 AC 192 ms
13,264 KB
testcase_13 AC 290 ms
13,104 KB
testcase_14 AC 94 ms
13,172 KB
testcase_15 AC 92 ms
13,376 KB
testcase_16 AC 91 ms
13,060 KB
testcase_17 AC 91 ms
13,216 KB
testcase_18 AC 92 ms
13,064 KB
testcase_19 AC 92 ms
13,104 KB
testcase_20 AC 95 ms
13,068 KB
testcase_21 AC 91 ms
13,068 KB
testcase_22 AC 91 ms
13,088 KB
testcase_23 AC 93 ms
13,368 KB
testcase_24 AC 107 ms
13,156 KB
testcase_25 AC 91 ms
13,216 KB
testcase_26 AC 187 ms
13,196 KB
testcase_27 AC 179 ms
13,068 KB
testcase_28 AC 184 ms
13,304 KB
testcase_29 AC 189 ms
13,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

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

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