結果

問題 No.8023 素数判定するだけ
ユーザー pirozhki
提出日時 2018-05-31 22:59:28
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 2 ms / 1,000 ms
コード長 391 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 59,588 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-06-30 08:43:57
合計ジャッジ時間 4,993 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>

using namespace std;

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

	vector<int> v(n);
	if (next(v.begin()) == v.end()) {
		cout << "NO" << endl;
		return n % n;
	}

	for (auto it = next(next(v.begin())); it != v.end(); it = next(it)) {
		if (!(n % distance(v.begin(), it))) {
			cout << "NO" << endl;
			return n % n;
		}
	}
	cout << "YES" << endl;
	return n % n;
}
0