結果

問題 No.312 置換処理
ユーザー mdj982
提出日時 2015-12-31 14:58:49
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 801 bytes
コンパイル時間 737 ms
コンパイル使用メモリ 91,628 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2024-11-15 12:00:36
合計ジャッジ時間 1,945 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 45
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <deque>
#include <string>
#include <tuple>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <random>
//#include "toollib.h"
#define INT_MAX 2147483647
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#pragma warning (disable:4018)

using namespace std;
typedef long long int lint;

//***** Main Program *****

int main() {
	lint n;
	cin >> n;
	if (n % 3 == 0) cout << 3 << endl;
	else if (n % 4 == 0) cout << 4 << endl;
	else {
		bool judge = true;
		for (lint i = 5; i <= sqrt(n); i = i + 2) {
			if (n%i == 0) {
				cout << i << endl;
				judge = false;
				break;
			}
		}
		if (judge) {
			if (n % 2 == 0) cout << n / 2 << endl;
			else cout << n << endl;
		}
	}
	return 0;
}
0