結果

問題 No.36 素数が嫌い!
ユーザー izryt(趣味)izryt(趣味)
提出日時 2016-01-14 02:30:07
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 694 bytes
コンパイル時間 1,386 ms
コンパイル使用メモリ 159,600 KB
実行使用メモリ 14,340 KB
最終ジャッジ日時 2023-10-19 23:02:06
合計ジャッジ時間 5,709 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 86 ms
14,340 KB
testcase_01 WA -
testcase_02 AC 90 ms
14,340 KB
testcase_03 AC 89 ms
14,340 KB
testcase_04 AC 87 ms
14,340 KB
testcase_05 AC 92 ms
14,340 KB
testcase_06 AC 87 ms
14,340 KB
testcase_07 AC 90 ms
14,340 KB
testcase_08 AC 87 ms
14,340 KB
testcase_09 AC 86 ms
14,340 KB
testcase_10 AC 85 ms
14,340 KB
testcase_11 AC 118 ms
14,340 KB
testcase_12 AC 186 ms
14,340 KB
testcase_13 AC 284 ms
14,340 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 85 ms
14,340 KB
testcase_17 AC 88 ms
14,340 KB
testcase_18 AC 86 ms
14,340 KB
testcase_19 AC 87 ms
14,340 KB
testcase_20 AC 98 ms
14,340 KB
testcase_21 AC 87 ms
14,340 KB
testcase_22 AC 86 ms
14,340 KB
testcase_23 AC 91 ms
14,340 KB
testcase_24 WA -
testcase_25 AC 88 ms
14,340 KB
testcase_26 AC 151 ms
14,340 KB
testcase_27 AC 175 ms
14,340 KB
testcase_28 AC 148 ms
14,340 KB
testcase_29 AC 188 ms
14,340 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 (!p[i] && n % i == 0) {
        cout << "YES" << endl;
        return 0;
    }

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