結果

問題 No.36 素数が嫌い!
ユーザー DialBirdDialBird
提出日時 2017-02-08 10:21:39
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 854 bytes
コンパイル時間 521 ms
コンパイル使用メモリ 65,908 KB
実行使用メモリ 10,612 KB
最終ジャッジ日時 2023-08-26 17:22:50
合計ジャッジ時間 2,763 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
6,400 KB
testcase_01 AC 64 ms
6,460 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 3 ms
4,376 KB
testcase_09 AC 3 ms
4,380 KB
testcase_10 AC 3 ms
4,380 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 48 ms
6,256 KB
testcase_15 AC 2 ms
4,376 KB
testcase_16 WA -
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 3 ms
4,380 KB
testcase_19 AC 34 ms
6,412 KB
testcase_20 AC 89 ms
10,188 KB
testcase_21 AC 64 ms
6,296 KB
testcase_22 AC 67 ms
6,412 KB
testcase_23 AC 41 ms
6,348 KB
testcase_24 AC 42 ms
6,256 KB
testcase_25 AC 44 ms
6,412 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define REP(i,first,last) for (int i=first;i<last;i++)

long long N;
vector<bool> prime_check_list(10000000 + 1, true);
vector<int> prime_list;

int main(){
  cin >> N;

  int sqrt_n = sqrt(N);

  prime_check_list[0] = false;
  prime_check_list[1] = false;

  // Nの平方根までの素数を発見
  for (int i=2;i<=sqrt_n;i++) {
    if (prime_check_list[i]) {
      prime_list.push_back(i);
      for (int j=i*2;j<sqrt_n;j+=i) {
        prime_check_list[j] = false;
      }
    }
  }

  int count = 0;
  for (auto p: prime_list) {
    while (N % p == 0) {
      N /= p;
      count++;
    }
    if (N == 1) break;
  }

  if (count >= 3) {
    cout << "YES" << endl;
  } else if (count == 2 || N != 1) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}
0