結果

問題 No.36 素数が嫌い!
ユーザー misora192misora192
提出日時 2020-06-13 21:27:23
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 802 bytes
コンパイル時間 1,494 ms
コンパイル使用メモリ 171,672 KB
実行使用メモリ 40,320 KB
最終ジャッジ日時 2023-09-08 04:41:56
合計ジャッジ時間 11,975 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 268 ms
36,064 KB
testcase_01 AC 266 ms
36,072 KB
testcase_02 AC 289 ms
35,668 KB
testcase_03 AC 292 ms
35,680 KB
testcase_04 AC 289 ms
35,680 KB
testcase_05 WA -
testcase_06 AC 291 ms
35,668 KB
testcase_07 AC 287 ms
35,732 KB
testcase_08 AC 263 ms
35,992 KB
testcase_09 AC 264 ms
36,084 KB
testcase_10 AC 261 ms
36,136 KB
testcase_11 TLE -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i=(0);i<(n);i++)

using namespace std;

typedef long long ll;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	ll n;
	cin >> n;

	ll max_n = 10101010;
	vector<bool> isprime(max_n, true);
	isprime[0] = isprime[1] = false;
	set<ll> primes;
	for(int i = 2; i < max_n; i++){
		if(isprime[i]){
			primes.insert(i);
			for(int j = 2 * i; j < max_n; j += i) isprime[j] = false;
		}
	}

	for(int i = 2; i * i <= n; i++){
		if(n % i) continue;

		if(primes.count(i) == 0 || primes.count(n / i) == 0){
			cout << "YES" << endl;
			exit(0);
		}
	}

	cout << "NO" << endl;
}

0