結果

問題 No.36 素数が嫌い!
ユーザー zaichu
提出日時 2015-12-30 00:29:08
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 789 ms / 5,000 ms
コード長 762 bytes
コンパイル時間 1,680 ms
コンパイル使用メモリ 165,096 KB
実行使用メモリ 78,596 KB
最終ジャッジ日時 2024-06-27 00:35:51
合計ジャッジ時間 11,742 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int check(long long int n){
	vector<long long int> data(sqrt(n)+1);
	for(int i = 2; i <= sqrt(n); i++) data[i] = i;
	for(int i = 2; i <= sqrt(n); i++){
		if(data[i]){
			for(int j = 0; i * (j + 2) <= sqrt(n); j++){
				data[i*(j + 2)] = 0;
			}
		}
	}
	sort(data.begin(),data.end());
	data.erase(unique(data.begin(),data.end()),data.end());
	data.erase(data.begin());
	//	for(auto a:data) cout << a << endl;
	int count = 0;
	for(int i = 0; i < data.size(); i++){
		while(n % data[i] == 0){
			n /= data[i];
			count++;
		}
	}
	if(n > 1) count++;
	//	cout << count << endl;
	return count;
}

int main(){
	long long int n;
	cin >> n;
	if(check(n) >= 3) cout << "YES" << endl;
	else cout << "NO" << endl;
	return 0;
}
0