結果

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

ソースコード

diff #

#include <iostream>
#include <cstdint>

using namespace std;

uint64_t func(uint64_t n) {
    if (n % 3 == 0) {
        return 3;
    }
    if (n % 4 == 0) {
        return 4;
    }
    if (n % 2 == 0) {
        n /= 2;
    }
    for (uint64_t i = 5; i * i <= n; i += 2) {
        if (n % i == 0) {
            return i;
        }
    }
    return n;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);

    uint64_t n;
    cin >> n;
    cout << func(n) << endl;
    return 0;
}
0