結果

問題 No.8023 素数判定するだけ
ユーザー south
提出日時 2017-04-12 22:06:42
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 338 bytes
コンパイル時間 506 ms
コンパイル使用メモリ 63,468 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-10-04 20:21:06
合計ジャッジ時間 3,533 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
#include <functional>
using namespace std;
int zero='a'%'a';
int one='b'%'a';
int two='c'%'a';
int p(int n){
	if(n==one)return false;
	for(int i=two;i<=sqrt(n);i=plus<int>()(i,one)){
		if(n%i==zero){
			return false;
		}
	}
	return true;
}
int main() {
	int n;cin>>n;
	cout<<(p(n)?"YES":"NO")<<endl;
}
0