結果
| 問題 |
No.8023 素数判定するだけ
|
| コンテスト | |
| ユーザー |
monnu
|
| 提出日時 | 2021-07-15 01:07:58 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 1,000 ms |
| コード長 | 1,241 bytes |
| コンパイル時間 | 697 ms |
| コンパイル使用メモリ | 79,220 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-04 01:28:02 |
| 合計ジャッジ時間 | 4,633 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
#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;
}
}
}
}
monnu