結果

問題 No.36 素数が嫌い!
ユーザー furon
提出日時 2023-06-17 16:50:28
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 102 ms / 5,000 ms
コード長 1,465 bytes
コンパイル時間 1,137 ms
コンパイル使用メモリ 127,288 KB
最終ジャッジ日時 2025-02-14 22:20:53
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

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