結果

問題 No.8023 素数判定するだけ
ユーザー latte0119latte0119
提出日時 2017-03-31 22:37:00
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 523 bytes
コンパイル時間 549 ms
コンパイル使用メモリ 59,124 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-04 17:03:48
合計ジャッジ時間 3,782 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int o=true;
int z;
int nex(int n){
    int t=o;
    for(;;){
        if(n&t){
            n^=t;
        }
        else{
            n|=t;
            return n;
        }
        t<<=o;
    }
}

int main(){
    int N;
    cin>>N;

    if(N==o){
        cout<<"NO"<<endl;
        return z;
    }

    for(int i=nex(o);i<N;i=nex(i)){
        if(N%i)continue;
        cout<<"NO"<<endl;
        return z;
    }
    cout<<"YES"<<endl;
    return z;
}
0