結果

問題 No.312 置換処理
ユーザー kapokapo
提出日時 2016-06-03 11:01:32
言語 C++11
(gcc 13.3.0)
結果
AC  
実行時間 12 ms / 2,000 ms
コード長 419 bytes
コンパイル時間 538 ms
コンパイル使用メモリ 59,064 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-15 12:06:57
合計ジャッジ時間 1,843 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cmath>

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ll long long

using namespace std;

int main(void)
{
	ll N;
	cin >> N;

	ll t = N;
	if(N >= 10000) t = sqrt(static_cast<ll>(N));

	int ans = 0;
	rep(i,3,t) {
		if(!(N%i)) {
			ans = i;
			break;
		}
	}

	if(!ans) {
		if(!(N%2) && N/2 > 2) cout << N/2 << endl;
		else cout << N << endl;
	}
	else cout << ans << endl;

	return 0;
}
0