結果

問題 No.8023 素数判定するだけ
ユーザー Pachicobue
提出日時 2020-02-06 00:31:50
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 579 bytes
コンパイル時間 700 ms
コンパイル使用メモリ 87,628 KB
最終ジャッジ日時 2025-01-08 22:26:50
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <functional>
constexpr int ONE = true;
constexpr int TWO = std::plus<int>{}(ONE,ONE);
constexpr int ZERO = std::minus<int>{}(ONE,ONE);
int main()
{
    int N;std::cin>>N;
    if(N==ONE){
        std::cout << "NO"<<std::endl;
        return ZERO;
    }
    for(int p = TWO; std::multiplies<int>{}(p,p)<=N;p=std::plus<int>{}(p,ONE)){
        if(N%p==ZERO){ 
            std::cout << "NO"<<std::endl;
            return ZERO;
        }
    }
    std::cout << "YES"<<std::endl;
    return ZERO;
}
0