結果

問題 No.312 置換処理
ユーザー Yang33
提出日時 2016-01-07 14:14:07
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 407 bytes
コンパイル時間 515 ms
コンパイル使用メモリ 59,824 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-15 12:01:01
合計ジャッジ時間 1,660 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<cmath>
using namespace std;
int main(void)
{
	long long int i, n, ans=0;

	cin >> n;

	if (n % 3 == 0) {
		cout << 3 << endl;
		return 0;
	}
	if (n % 4 == 0) {
		cout << 4 << endl;
		return 0;
	}
	for (i = 5; i <= sqrt(n); i+=2) {
		if (n%i == 0) {
			ans = i;
			break;
		}
	}
	if (n % 2 == 0&&ans==0)ans = n / 2;
	else if (ans == 0)ans = n;
	cout << ans << endl;


	return 0;
}
0