結果

問題 No.36 素数が嫌い!
ユーザー NotationNapNotationNap
提出日時 2015-05-01 03:16:23
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 73 ms / 5,000 ms
コード長 784 bytes
コンパイル時間 1,100 ms
コンパイル使用メモリ 144,276 KB
実行使用メモリ 13,416 KB
最終ジャッジ日時 2023-09-09 07:09:38
合計ジャッジ時間 4,381 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
13,096 KB
testcase_01 AC 70 ms
13,096 KB
testcase_02 AC 71 ms
13,188 KB
testcase_03 AC 70 ms
13,168 KB
testcase_04 AC 70 ms
13,108 KB
testcase_05 AC 72 ms
13,416 KB
testcase_06 AC 71 ms
13,076 KB
testcase_07 AC 71 ms
13,168 KB
testcase_08 AC 70 ms
13,100 KB
testcase_09 AC 70 ms
13,184 KB
testcase_10 AC 71 ms
13,348 KB
testcase_11 AC 69 ms
13,180 KB
testcase_12 AC 71 ms
13,188 KB
testcase_13 AC 70 ms
13,392 KB
testcase_14 AC 71 ms
13,096 KB
testcase_15 AC 71 ms
13,188 KB
testcase_16 AC 70 ms
13,176 KB
testcase_17 AC 2 ms
4,376 KB
testcase_18 AC 70 ms
13,116 KB
testcase_19 AC 70 ms
13,120 KB
testcase_20 AC 70 ms
13,272 KB
testcase_21 AC 70 ms
13,092 KB
testcase_22 AC 70 ms
13,168 KB
testcase_23 AC 70 ms
13,080 KB
testcase_24 AC 70 ms
13,304 KB
testcase_25 AC 70 ms
13,396 KB
testcase_26 AC 70 ms
13,088 KB
testcase_27 AC 70 ms
13,300 KB
testcase_28 AC 70 ms
13,100 KB
testcase_29 AC 70 ms
13,092 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 k = N;
		int count = 0;
		Int pp = 1;
		for (int i = 0; i < MAX_N; i++) if (is_prime[i]) {
			while (k % i == 0) {
				count++;
				pp *= i;
				k /= i;
			}
		}
		if (count >= 3 || count == 2 && pp != N) {
			cout << "YES" << endl;
		}
		else {
			cout << "NO" << endl;
		}
	}
}
0