結果

問題 No.312 置換処理
ユーザー zaichuzaichu
提出日時 2015-12-26 02:09:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 593 bytes
コンパイル時間 1,490 ms
コンパイル使用メモリ 166,684 KB
実行使用メモリ 10,892 KB
最終ジャッジ日時 2023-10-19 03:56:03
合計ジャッジ時間 3,974 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
9,044 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 52 ms
10,892 KB
testcase_06 AC 28 ms
7,528 KB
testcase_07 AC 44 ms
9,836 KB
testcase_08 AC 40 ms
9,572 KB
testcase_09 AC 19 ms
6,012 KB
testcase_10 AC 22 ms
6,540 KB
testcase_11 AC 42 ms
9,572 KB
testcase_12 AC 28 ms
7,528 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 17 ms
5,484 KB
testcase_36 WA -
testcase_37 RE -
testcase_38 WA -
testcase_39 AC 15 ms
5,484 KB
testcase_40 AC 3 ms
4,348 KB
testcase_41 RE -
testcase_42 AC 3 ms
4,348 KB
testcase_43 WA -
testcase_44 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
	long long int n;
	cin >> n;
	n += 2;
	vector<long long int>data(sqrt(n));
	for(long long int i = 2; i < sqrt(n); i++){
		data[i] = i;
	}
	for(long long int i = 2; i < sqrt(n); i++){
		if(data[i]){
			for(long long int j = 0; i * (j + 2) < sqrt(n); j++){
				data[i * (j + 2)] = 0;
			}
		}
	}
	sort(data.begin(),data.end());
	data.erase(unique(data.begin(),data.end()),data.end());
	data.erase(data.begin());
	for(int i = 0; i < data.size(); i++){
		if(n % data[i] == 2){
			cout << data[i] << endl;
			break;
		}
	}
   	return 0;
}
0