結果

問題 No.312 置換処理
ユーザー HaarHaar
提出日時 2016-04-13 00:50:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 512 bytes
コンパイル時間 447 ms
コンパイル使用メモリ 59,144 KB
実行使用メモリ 13,756 KB
最終ジャッジ日時 2024-04-15 00:20:01
合計ジャッジ時間 4,331 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,756 KB
testcase_01 AC 4 ms
6,816 KB
testcase_02 AC 7 ms
6,944 KB
testcase_03 AC 5 ms
6,944 KB
testcase_04 AC 2 ms
6,944 KB
testcase_05 AC 2 ms
6,944 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 6 ms
6,940 KB
testcase_08 AC 2 ms
6,940 KB
testcase_09 AC 1 ms
6,944 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 3 ms
6,944 KB
testcase_12 AC 1 ms
6,944 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 1 ms
6,940 KB
testcase_17 AC 1 ms
6,944 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 WA -
testcase_20 AC 2 ms
6,940 KB
testcase_21 AC 1 ms
6,940 KB
testcase_22 AC 1 ms
6,944 KB
testcase_23 WA -
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 1 ms
6,944 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,944 KB
testcase_31 TLE -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>
using namespace std;

bool isPrime(long long int n){
	long long int sq = sqrt(n);
	if(n == 1)return false;
	if(n == 2)return true;
	if(n % 2 == 0)return false;
	for(long long int i=3;i<=sq;i+=2){
		if(n % i == 0)return false;
	}
	return true;
}

int main() {
	long long int n;
	
	cin >> n;
	if(n % 2 == 0)n /= 2;
	if(isPrime(n)){
			cout << n << endl;
	}else{
		for(long long int i=3; i<=n; ++i){
			if(n % i == 0){
				cout << i << endl;
				break;
			}
		}
	}

	return 0;
}
0