結果

問題 No.36 素数が嫌い!
ユーザー izryt(趣味)izryt(趣味)
提出日時 2016-01-14 03:06:31
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 284 ms / 5,000 ms
コード長 666 bytes
コンパイル時間 1,183 ms
コンパイル使用メモリ 144,792 KB
実行使用メモリ 13,360 KB
最終ジャッジ日時 2023-09-09 07:31:07
合計ジャッジ時間 4,018 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
13,228 KB
testcase_01 AC 64 ms
13,060 KB
testcase_02 AC 5 ms
13,168 KB
testcase_03 AC 5 ms
13,084 KB
testcase_04 AC 5 ms
13,232 KB
testcase_05 AC 6 ms
13,064 KB
testcase_06 AC 6 ms
13,196 KB
testcase_07 AC 6 ms
13,088 KB
testcase_08 AC 6 ms
13,196 KB
testcase_09 AC 5 ms
13,100 KB
testcase_10 AC 6 ms
13,144 KB
testcase_11 AC 57 ms
13,288 KB
testcase_12 AC 184 ms
13,172 KB
testcase_13 AC 284 ms
13,052 KB
testcase_14 AC 47 ms
13,060 KB
testcase_15 AC 6 ms
13,192 KB
testcase_16 AC 6 ms
13,068 KB
testcase_17 AC 6 ms
13,360 KB
testcase_18 AC 5 ms
13,196 KB
testcase_19 AC 29 ms
13,048 KB
testcase_20 AC 90 ms
13,048 KB
testcase_21 AC 62 ms
13,104 KB
testcase_22 AC 64 ms
13,276 KB
testcase_23 AC 35 ms
13,192 KB
testcase_24 AC 53 ms
13,304 KB
testcase_25 AC 37 ms
13,124 KB
testcase_26 AC 140 ms
13,228 KB
testcase_27 AC 156 ms
13,052 KB
testcase_28 AC 136 ms
13,052 KB
testcase_29 AC 178 ms
13,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

bool p[10000001];

ll n;

void sieve()
{
    for (ll i = 2; i * i <= n; ++i) {
        if (p[i]) for (ll j = i + i; j * j <= n; 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