結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
9,104 KB
testcase_01 AC 32 ms
8,380 KB
testcase_02 AC 50 ms
10,952 KB
testcase_03 AC 51 ms
10,952 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 48 ms
10,952 KB
testcase_06 AC 27 ms
7,588 KB
testcase_07 AC 42 ms
9,896 KB
testcase_08 AC 38 ms
9,632 KB
testcase_09 AC 18 ms
6,072 KB
testcase_10 AC 22 ms
6,600 KB
testcase_11 AC 40 ms
9,632 KB
testcase_12 AC 26 ms
7,588 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 2 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
testcase_25 AC 2 ms
4,348 KB
testcase_26 AC 1 ms
4,348 KB
testcase_27 AC 1 ms
4,348 KB
testcase_28 AC 2 ms
4,348 KB
testcase_29 AC 2 ms
4,348 KB
testcase_30 AC 7 ms
4,348 KB
testcase_31 AC 10 ms
4,752 KB
testcase_32 AC 6 ms
4,348 KB
testcase_33 AC 16 ms
5,544 KB
testcase_34 AC 16 ms
5,544 KB
testcase_35 AC 16 ms
5,544 KB
testcase_36 AC 2 ms
4,348 KB
testcase_37 AC 2 ms
4,348 KB
testcase_38 AC 1 ms
4,348 KB
testcase_39 AC 14 ms
5,544 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 2 ms
4,348 KB
testcase_44 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main(){
    long long int n;
    cin >> n;
    vector<long long int>data(sqrt(n) + 1);
    //	cout << (n - 2) / 2 << endl;
	if(n == 3){
		cout << 3 << endl;
		return 0;
	}	
    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());
    for(int i = 0; i < 2; i++) data.erase(data.begin());
	data.push_back(4);
    for(int i = 0; i < data.size(); i++){
        if(n % data[i] == 0){
			cout << data[i] << endl;
            return 0;
        }
    }
    if(n % 2 == 0 and n != 4) cout << n / 2 << endl;
    else cout << n << endl;
   	return 0;
}
0