結果

問題 No.414 衝動
ユーザー dgd1724dgd1724
提出日時 2016-10-20 06:28:15
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 812 bytes
コンパイル時間 1,550 ms
コンパイル使用メモリ 159,820 KB
実行使用メモリ 426,752 KB
最終ジャッジ日時 2024-05-02 20:24:18
合計ジャッジ時間 6,888 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>

//const static double	de_PI	= 3.14159265358979323846;
//const static int	de_MOD	= 1000000007;
//const static int	de_MAX	= 999999999;
//const static int	de_MIN = -999999999;

int main(void) {

	unsigned long long M = 0;
	std::cin >> M;

	if (M % 2 == 0) {
		std::cout << "2 " << M / 2 << std::endl;
		return 0;
	}

	switch (M) {
	case 1:std::cout << "1 1" << std::endl; return 0;
	case 3:std::cout << "1 3" << std::endl; return 0;
	case 5:std::cout << "1 5" << std::endl; return 0;
	case 7:std::cout << "1 7" << std::endl; return 0;
	}

	std::vector<bool> flg(M + 1, true);
	for (int i = 3; i*i <= M; i += 2) {
		if (flg[i]) {
			if (M%i == 0) {
				std::cout << i << " " << M / i << std::endl;
				return 0;
			}
			for (int j = 2; j*i <= M; j++) {
				flg[j*i] = false;
			}
		}
	}
}

0