結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
9,096 KB
testcase_01 WA -
testcase_02 AC 49 ms
10,944 KB
testcase_03 WA -
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 47 ms
10,944 KB
testcase_06 AC 26 ms
7,580 KB
testcase_07 AC 41 ms
9,888 KB
testcase_08 AC 36 ms
9,624 KB
testcase_09 AC 18 ms
6,064 KB
testcase_10 AC 20 ms
6,592 KB
testcase_11 AC 38 ms
9,624 KB
testcase_12 AC 25 ms
7,580 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 AC 2 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 WA -
testcase_26 AC 2 ms
4,348 KB
testcase_27 WA -
testcase_28 AC 2 ms
4,348 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 5 ms
4,348 KB
testcase_33 AC 16 ms
5,536 KB
testcase_34 AC 15 ms
5,536 KB
testcase_35 AC 15 ms
5,536 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 WA -
testcase_39 AC 14 ms
5,536 KB
testcase_40 AC 4 ms
4,348 KB
testcase_41 AC 2 ms
4,348 KB
testcase_42 AC 3 ms
4,348 KB
testcase_43 AC 1 ms
4,348 KB
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 - 2) + 1);
    for(long long int i = 2; i <= sqrt(n - 2); i++){
        data[i] = i;
    }
    for(long long int i = 2; i <= sqrt(n - 2); i++){
        if(data[i]){
            for(long long int j = 0; i * (j + 2) <= sqrt(n - 2); 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;
			return 0;
        }
	}
    cout << n - 2 << endl;
   	return 0;
}
0