結果

問題 No.8023 素数判定するだけ
ユーザー ei1333333ei1333333
提出日時 2017-03-31 22:39:35
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 465 bytes
コンパイル時間 527 ms
コンパイル使用メモリ 58,516 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-10-04 19:50:24
合計ジャッジ時間 3,528 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cmath>

using namespace std;

int zero, base, one;

bool sosu(int idx)
{
  one = (int) log(M_PI);
  base = plus< int >{}(base, one);
  base = plus< int >{}(base, one);
  if(idx < base) return (false);
  for(; multiplies< int >{}(base, base) <= idx; base = plus< int >{}(base, one)) {
    if(idx % base == zero) return (false);
  }
  return (true);
}

int main()
{
  int idx;
  cin >> idx;
  cout << (sosu(idx) ? "YES" : "NO") << endl;
}
0