結果

問題 No.36 素数が嫌い!
ユーザー fushime2
提出日時 2017-01-09 14:08:02
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 798 bytes
コンパイル時間 884 ms
コンパイル使用メモリ 63,304 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-12-18 00:18:09
合計ジャッジ時間 2,985 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 17 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;

vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i = 1; i*i <= n; ++i) {
        if (n%i == 0) {
            res.push_back(i);
            if (i != n / i) res.push_back(n / i);
        }
    }
    return res;
}

bool is_prime(ll x) {
    for (ll i = 2; i*i <= x; ++i) {
        if (x%i == 0) return false;
    }
    return true;
}

bool is_ok(ll x) {
    if (x <= 2) return false;
    if (is_prime(x)) return false;
    vector<ll> divs = divisor(x);

    for (auto& d : divs) {
        if (!is_prime(d)) return true;
    }
    return false;
}

int main(void) {
    ll x;
    cin >> x;
    cout << (is_ok(x) ? "YES" : "NO") << endl;

    return 0;
}
0