結果

問題 No.36 素数が嫌い!
ユーザー izryt(趣味)izryt(趣味)
提出日時 2016-01-14 03:02:39
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 706 bytes
コンパイル時間 1,223 ms
コンパイル使用メモリ 159,740 KB
実行使用メモリ 13,448 KB
最終ジャッジ日時 2023-10-19 23:02:43
合計ジャッジ時間 4,944 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 70 ms
13,428 KB
testcase_02 AC 5 ms
13,428 KB
testcase_03 AC 5 ms
13,428 KB
testcase_04 WA -
testcase_05 AC 6 ms
13,428 KB
testcase_06 AC 5 ms
13,428 KB
testcase_07 AC 5 ms
13,428 KB
testcase_08 AC 5 ms
13,428 KB
testcase_09 AC 5 ms
13,428 KB
testcase_10 AC 5 ms
13,428 KB
testcase_11 AC 59 ms
13,428 KB
testcase_12 AC 187 ms
13,428 KB
testcase_13 WA -
testcase_14 AC 50 ms
13,428 KB
testcase_15 AC 5 ms
13,428 KB
testcase_16 AC 5 ms
13,428 KB
testcase_17 AC 5 ms
13,428 KB
testcase_18 AC 5 ms
13,428 KB
testcase_19 AC 31 ms
13,428 KB
testcase_20 RE -
testcase_21 AC 65 ms
13,428 KB
testcase_22 AC 72 ms
13,428 KB
testcase_23 AC 37 ms
13,428 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 144 ms
13,428 KB
testcase_27 AC 160 ms
13,428 KB
testcase_28 AC 139 ms
13,428 KB
testcase_29 AC 181 ms
13,428 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] || ((n / i) * (n / i) <= n ? p[n / i] : !is_prime(n / i)))) {
        cout << "YES" << endl;
        return 0;
    }

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