結果

問題 No.36 素数が嫌い!
ユーザー furonfuron
提出日時 2023-06-17 16:50:28
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 96 ms / 5,000 ms
コード長 1,465 bytes
コンパイル時間 1,308 ms
コンパイル使用メモリ 128,728 KB
実行使用メモリ 4,388 KB
最終ジャッジ日時 2023-09-07 13:04:41
合計ジャッジ時間 3,708 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
4,384 KB
testcase_01 AC 77 ms
4,384 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,384 KB
testcase_06 AC 2 ms
4,384 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 2 ms
4,384 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 34 ms
4,380 KB
testcase_12 AC 94 ms
4,380 KB
testcase_13 AC 96 ms
4,380 KB
testcase_14 AC 61 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,380 KB
testcase_18 AC 1 ms
4,388 KB
testcase_19 AC 38 ms
4,380 KB
testcase_20 AC 95 ms
4,380 KB
testcase_21 AC 71 ms
4,384 KB
testcase_22 AC 74 ms
4,384 KB
testcase_23 AC 46 ms
4,384 KB
testcase_24 AC 49 ms
4,384 KB
testcase_25 AC 51 ms
4,384 KB
testcase_26 AC 92 ms
4,380 KB
testcase_27 AC 82 ms
4,384 KB
testcase_28 AC 88 ms
4,384 KB
testcase_29 AC 91 ms
4,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <queue>
#include <map>
#include <bitset>
#include <set>
#include <stack>
#include <numeric>
#include <unordered_map>
#include <random>

using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vs = vector<string>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pdd = pair<double, double>;
using vpii = vector<pii>;
using vpll = vector<pll>;
using vpdd = vector<pdd>;
const int inf = (1 << 30) - 1;
const ll INF = 1LL << 60;
//const int MOD = 1000000007;
const int MOD = 998244353;

void divisors(ll x, vector<ll>& v) {
	for (ll i = 1; i * i <= x; i++) {
		if (x % i == 0) {
			v.push_back(i);
			if (x / i != i) v.push_back(x / i);
		}
	}
	sort(v.begin(), v.end());

	return;
}
bool isPrime(ll n) {
	if (n < 2) return false;
	if (n == 2) return true;
	if (n % 2 == 0) return false;

	int imax = sqrt(n);
	for (int i = 3; i <= imax; i++) {
		if (n % i == 0) return false;
	}
	return true;
}

int main() {
	ll n;
	cin >> n;
	vl div;
	divisors(n, div);
	for (int i = 0; i < div.size(); i++) {
		if (div[i] == 1 || div[i] == n) continue;
		if (isPrime(div[i])) continue;
		cout << "YES" << endl;
		return 0;
	}
	cout << "NO" << endl;

	return 0;
}
0