結果
| 問題 | No.36 素数が嫌い! |
| コンテスト | |
| ユーザー |
fushime2
|
| 提出日時 | 2017-01-09 14:13:58 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 800 bytes |
| 記録 | |
| コンパイル時間 | 550 ms |
| コンパイル使用メモリ | 64,088 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-12-18 00:18:12 |
| 合計ジャッジ時間 | 2,779 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 WA * 9 |
ソースコード
#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 x != 1;
}
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;
}
fushime2