結果

問題 No.414 衝動
ユーザー willowoooowillowoooo
提出日時 2016-08-26 23:22:42
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 702 bytes
コンパイル時間 503 ms
コンパイル使用メモリ 59,940 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-26 03:58:56
合計ジャッジ時間 3,113 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

vector<int> sieve(int n) {
	vector<int> res(n);
	for (int i = 0; i < n; i++)
	{
		res[i] = 1;
	}
	if (n >= 2)
		res[0] = res[1] = 0;
	else {
		for (int i = 0; i < n; i++)
		{
			res[i] = 0;
		}
	}
	for (int i = 2; i*i < n; i++)
	{
		if (res[i] == 1) {
			for (int j = 2 * i; j < n; j += i)
			{
				res[j] = 0;

			}
		}
	}
	return res;
}

int main() {
	long long n;
	cin >> n;
	if (n % 2 == 0) {
		cout << 2 << " " << n / 2 << endl;
		return 0;
	}
	vector<int> v = sieve(n);
	for (int i = 2; i < n; i++)
	{
		if (n%i == 0 && v[i] == 1) {
			cout << i << " " << n/i << endl;
			return 0;
		}
	}
		
		cout << 1 << " " << n << endl;
		return 0;
}
0