結果

問題 No.36 素数が嫌い!
ユーザー DialBird
提出日時 2017-02-12 21:14:37
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 108 ms / 5,000 ms
コード長 709 bytes
コンパイル時間 658 ms
コンパイル使用メモリ 74,696 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-27 00:55:52
合計ジャッジ時間 2,608 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <vector>
#include <array>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>

using namespace std;

#define REP(i,first,last) for (int i=first;i<last;++i)
#define MAX(x,y) (x > y ? x : y)
#define MIN(x,y) (x < y ? x : y)

long N;

vector<int> factor(long n){
  vector<int> res;
  int num = 2;
  int sqrt_n = sqrt(n);
  while (n > 1) {
    if (n == 1) break;
    if (num > sqrt_n) {
      res.push_back(n);
      break;
    }

    while (n % num == 0) {
      n /= num;
      res.push_back(num);
    }
    ++num;
  }
  return res;
}

int main(){
  cin >> N;

  vector<int> res = factor(N);
  cout << (res.size() > 2 ? "YES" : "NO") << endl;
}
0