結果

問題 No.36 素数が嫌い!
ユーザー motxx
提出日時 2014-10-08 01:18:01
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 827 bytes
コンパイル時間 1,437 ms
コンパイル使用メモリ 157,652 KB
実行使用メモリ 13,312 KB
最終ジャッジ日時 2024-12-30 08:07:56
合計ジャッジ時間 4,427 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 24 WA * 2
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define MAX 10000010
bool prime[MAX];

typedef unsigned long long ull;

void sieve() {
  fill(prime, prime+MAX, true);
  prime[0] = prime[1] = false;
  
  for(ull i=2 ; i*i<MAX ; i++){
    if(prime[i]){
      for(ull j=i*i ; j<MAX ; j+=i){
	prime[j] = false;
      }
    }
  }
}
  bool isPrime(ull a) { for(ull i=2; i*i <=a; i++) if(a%i == 0) return false; return true; }

int main() {

  sieve();
  ull N; cin >> N;
  
  if(N == 1) { cout << "NO\n"; return 0; }
  
  if(isPrime(N))  { cout << "NO\n"; return 0; }
  
  int cnt = 0;
  ull K = N;
  for(ull i=2; i*i<=K; i++) {
    if(prime[i]) {
      while(N % i == 0) {
	N /= i;
	cnt ++;
      }
    }
  }
  
  if(cnt >= 2) cout << "YES\n";
  else cout << "NO\n";
  
  return 0;
}
0