結果
| 問題 |
No.36 素数が嫌い!
|
| コンテスト | |
| ユーザー |
fushime2
|
| 提出日時 | 2017-01-09 14:01:04 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 785 bytes |
| コンパイル時間 | 524 ms |
| コンパイル使用メモリ | 63,804 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-12-18 00:16:50 |
| 合計ジャッジ時間 | 2,723 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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 true;
}
bool is_ok(ll x) {
if (x <= 2) return false;
if (is_prime(x)) return false;
vector<ll> divs = divisor(x);
if (divs.size() == 1)
return false;
else
return true;
}
int main(void) {
ll x;
cin >> x;
cout << (is_ok(x) ? "YES" : "NO") << endl;
return 0;
}
fushime2