結果

問題 No.36 素数が嫌い!
ユーザー kongarishisyamokongarishisyamo
提出日時 2016-06-09 12:14:01
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 506 bytes
コンパイル時間 530 ms
コンパイル使用メモリ 59,764 KB
実行使用メモリ 13,056 KB
最終ジャッジ日時 2024-04-17 12:12:12
合計ジャッジ時間 5,645 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 AC 1 ms
5,376 KB
testcase_03 WA -
testcase_04 AC 1 ms
5,376 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 3 ms
5,376 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 2 ms
5,376 KB
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 WA -
testcase_16 AC 1 ms
5,376 KB
testcase_17 AC 1 ms
5,376 KB
testcase_18 WA -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>

using namespace std;

#define MAX 10000000
bool zaru[MAX+1];
vector<long long> pr;

int main(){

  long long N;
  long long fN;

  cin>>N;

  fN=N;
  for(int i=2;i*i<=N;i++) zaru[i]=true;

  for(int i=2;i*i<=N;i++){
    if(zaru[i]){
      pr.push_back(i);
      for(int j=i*2;j*j<=N;j+=i) zaru[i]=false;
    }
  }

  for(int i=0;i<pr.size();i++){
    if(N%pr[i]==0){
      N/=pr[i];
      i--;
    }
  }

  if(N!=1&&N!=fN) cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}
0