結果

問題 No.8023 素数判定するだけ
ユーザー merom686
提出日時 2017-09-23 14:01:46
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 508 bytes
コンパイル時間 615 ms
コンパイル使用メモリ 73,644 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-14 04:10:38
合計ジャッジ時間 4,380 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int zero, one = !zero;

void inc(int& i) {
    for (int m = one;; m <<= one) {
        i ^= m;
        if (i & m) break;
    }
}

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

    bool b = n > one;
    for (int i = one << one; i < n; inc(i)) {
        if (!(n % i)) b = false;
    }

    cout << (b ? "YES" : "NO") << endl;

    return zero;
}
0