結果

問題 No.36 素数が嫌い!
ユーザー tnakao0123tnakao0123
提出日時 2016-03-03 19:02:27
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 66 ms / 5,000 ms
コード長 1,155 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 13,408 KB
最終ジャッジ日時 2023-09-09 07:33:31
合計ジャッジ時間 2,593 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
13,320 KB
testcase_01 AC 47 ms
13,332 KB
testcase_02 AC 5 ms
13,052 KB
testcase_03 AC 5 ms
13,196 KB
testcase_04 AC 5 ms
13,280 KB
testcase_05 AC 6 ms
13,324 KB
testcase_06 AC 6 ms
13,088 KB
testcase_07 AC 6 ms
13,056 KB
testcase_08 AC 6 ms
13,052 KB
testcase_09 AC 6 ms
13,052 KB
testcase_10 AC 6 ms
13,096 KB
testcase_11 AC 23 ms
13,304 KB
testcase_12 AC 66 ms
13,056 KB
testcase_13 AC 65 ms
13,408 KB
testcase_14 AC 27 ms
13,140 KB
testcase_15 AC 6 ms
13,052 KB
testcase_16 AC 6 ms
13,384 KB
testcase_17 AC 6 ms
13,224 KB
testcase_18 AC 6 ms
13,168 KB
testcase_19 AC 27 ms
13,136 KB
testcase_20 AC 64 ms
13,068 KB
testcase_21 AC 49 ms
13,096 KB
testcase_22 AC 51 ms
13,144 KB
testcase_23 AC 31 ms
13,052 KB
testcase_24 AC 26 ms
13,048 KB
testcase_25 AC 33 ms
13,052 KB
testcase_26 AC 39 ms
13,144 KB
testcase_27 AC 56 ms
13,076 KB
testcase_28 AC 37 ms
13,088 KB
testcase_29 AC 62 ms
13,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

/* -*- coding: utf-8 -*-
 *
 * 36.cc: No.36 素数が嫌い! - yukicoder
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_P = 10000000;

/* typedef */

typedef long long ll;

/* global variables */

bool primes[MAX_P + 1];

/* subroutines */

void gen_primes(int maxp) {
  memset(primes, true, sizeof(primes));
  primes[0] = primes[1] = false;

  int p;
  for (p = 2; p * p <= maxp; p++)
    if (primes[p])
      for (int q = p * p; q <= maxp; q += p) primes[q] = false;
}

/* main */

int main() {
  ll n;
  cin >> n;

  ll maxp;
  for (maxp = 1; maxp * maxp < n; maxp++);
  gen_primes(maxp);

  int c = 0;
  for (int p = 2; n > 1 && p <= maxp; p++)
    if (primes[p]) {
      while (n % p == 0) c++, n /= p;
      if (c > 2) {
	puts("YES");
	return 0;
      }
    }

  if (c > 1 && n > 1) puts("YES");
  else puts("NO");
  return 0;
}
0