結果

問題 No.36 素数が嫌い!
ユーザー mmn15277198mmn15277198
提出日時 2021-02-21 12:19:54
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,150 bytes
コンパイル時間 928 ms
コンパイル使用メモリ 96,100 KB
実行使用メモリ 7,676 KB
最終ジャッジ日時 2023-10-19 14:14:33
合計ジャッジ時間 13,401 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 TLE -
testcase_01 -- -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
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<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<math.h>
#include<iomanip>
#include<stack>
#include<queue>
#include<set>
#include<map>
 
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
 
//const ll mod = 1000000007;
const ll mod = 998244353;
const ld pi = 3.14159265358979;

ll gcd(ll a , ll b){
	if(a < b)swap(a , b);
	if(b == 0)return 1;
	if(a % b == 0)return b;
	else return gcd(b , a % b);
}

bool isPrime(ll x){
	if(x == 2 || x == 3 || x == 5 || x == 7){
		return true;
	}
	for(int i = 3; i * i <= x; i++){
		if(x % i == 0)return false;
	}
	return true;
}

int main(){	
	cin.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	ll n;
	cin >> n;
	vector<ll> v;
	for(ll i = 1; i * i <= n; i++){
		if(n % i == 0){
			v.push_back(i);
			if(i != n / i)v.push_back(n / i);
		}
	}
	bool ok = false;
	for(int i = 0; i < v.size(); i++){
		if(isPrime(v[i]) == false && v[i] != 1 && v[i] != n){
			ok = true;
			break;
		}
	}
	if(ok){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}

	return 0;
}
0