結果

問題 No.3023 素数判定するだけ
ユーザー monnumonnu
提出日時 2021-07-15 01:07:58
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 1,241 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 78,576 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-17 03:46:20
合計ジャッジ時間 4,411 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cassert>
#include <map>
#include <queue>
using namespace std;

int main(){
  int N;
  cin>>N;
  int one=(int)true;
  int two=one<<one;
  int three=two|one;
  int four=one<<two;
  int five=four|one;
  int seven=four|three;
  int eight=one<<three;
  int eleven=eight|three;
  int thirteen=eight|five;
  int sixteen=one<<four;
  int seventeen=sixteen|one;
  int nineteen=sixteen|three;
  int twentythree=sixteen|seven;
  int twentynine=sixteen|thirteen;
  int thirtyone=sixteen|eight|seven;

  vector<int> p;
  p.push_back(two);
  p.push_back(three);
  p.push_back(five);
  p.push_back(seven);
  p.push_back(eleven);
  p.push_back(thirteen);
  p.push_back(seventeen);
  p.push_back(nineteen);
  p.push_back(twentythree);
  p.push_back(twentynine);
  p.push_back(thirtyone);

  int zero=one&two;

  if(N==one){
    cout<<"NO"<<endl;
  }else{
    bool flag=true;
    for(auto x:p){
      if(N==x){
        cout<<"YES"<<endl;
        flag=false;
      }
    }
    if(flag){
      for(auto x:p){
        if(N%x==zero){
          flag=false;
        }
      }
      if(flag){
        cout<<"YES"<<endl;
      }else{
        cout<<"NO"<<endl;
      }
    }
  }
}
0