結果

問題 No.414 衝動
ユーザー Grun1396Grun1396
提出日時 2017-02-20 20:31:31
言語 C++11
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 522 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 58,260 KB
実行使用メモリ 8,752 KB
最終ジャッジ日時 2023-08-28 21:38:13
合計ジャッジ時間 3,709 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
7,476 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 7 ms
4,376 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 TLE -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <math.h>
using namespace std;

long long int is_prime(long long int n){
	switch(n){
		case 0:
		case 1:	return 1;
		case 2:	return -1;
	}

	if(n%2 == 0) return 2;//2を返せばおk

	for(int d = 3; d*d <= n; d+=2){
		if(n%d == 0) return d;//dを返せばおk
	}

	return -1;
}

int main(){
	long long int m;
	cin >> m;
	int p =	is_prime(m);
	if(p == -1){
		cout << 1 << " " << m << endl;
	}//素数なので 1 mを返却する
	else {
		cout << p << " " << m/p << endl;
	}

	return 0;
}
0