結果

問題 No.36 素数が嫌い!
ユーザー NotationNapNotationNap
提出日時 2015-05-01 03:15:22
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 1,492 ms
コンパイル使用メモリ 144,324 KB
実行使用メモリ 13,384 KB
最終ジャッジ日時 2023-09-19 04:47:32
合計ジャッジ時間 5,361 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 75 ms
13,108 KB
testcase_01 AC 75 ms
13,124 KB
testcase_02 AC 81 ms
13,312 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 74 ms
13,120 KB
testcase_06 WA -
testcase_07 AC 76 ms
13,108 KB
testcase_08 AC 75 ms
13,384 KB
testcase_09 AC 75 ms
13,104 KB
testcase_10 AC 74 ms
13,248 KB
testcase_11 AC 75 ms
13,228 KB
testcase_12 AC 74 ms
13,136 KB
testcase_13 WA -
testcase_14 AC 74 ms
13,212 KB
testcase_15 AC 74 ms
13,168 KB
testcase_16 AC 76 ms
13,108 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 79 ms
13,068 KB
testcase_19 AC 76 ms
13,120 KB
testcase_20 AC 74 ms
13,168 KB
testcase_21 AC 76 ms
13,192 KB
testcase_22 AC 77 ms
13,128 KB
testcase_23 AC 76 ms
13,280 KB
testcase_24 AC 75 ms
13,280 KB
testcase_25 AC 73 ms
13,228 KB
testcase_26 AC 73 ms
13,164 KB
testcase_27 AC 74 ms
13,064 KB
testcase_28 AC 75 ms
13,056 KB
testcase_29 AC 74 ms
13,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

typedef long long Int;
#define REP(i,n) for(int (i)=0;(i)<(int)(n);++(i))

const int MAX_N = 10000000 + 10;
bool is_prime[MAX_N];

int main() {
	Int N; cin >> N;
	if (N == 1) {
		cout << "NO" << endl;
	}
	else {
		for (int i = 0; i < MAX_N; i++) is_prime[i] = true;
		is_prime[0] = is_prime[1] = false;
		for (int i = 2; i * i <= MAX_N; i++) {
			if (is_prime[i]) {
				for (int j = i * i; j < MAX_N; j += i) {
					is_prime[j] = false;
				}
			}
		}

		int count = 0;
		Int pp = 1;
		for (int i = 0; i < MAX_N; i++) if (is_prime[i]) {
			while (N % i == 0) {
				count++;
				pp *= i;
				N /= i;
			}
		}
		if (count >= 3 || count == 2 && pp != N) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}
0