結果

問題 No.312 置換処理
ユーザー crazybbb3crazybbb3
提出日時 2016-11-28 22:33:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 73 ms / 2,000 ms
コード長 1,909 bytes
コンパイル時間 2,101 ms
コンパイル使用メモリ 77,936 KB
実行使用メモリ 51,092 KB
最終ジャッジ日時 2024-04-27 10:48:25
合計ジャッジ時間 5,813 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
50,400 KB
testcase_01 AC 72 ms
51,044 KB
testcase_02 AC 73 ms
51,000 KB
testcase_03 AC 73 ms
51,092 KB
testcase_04 AC 53 ms
50,460 KB
testcase_05 AC 54 ms
50,432 KB
testcase_06 AC 58 ms
50,500 KB
testcase_07 AC 65 ms
50,364 KB
testcase_08 AC 55 ms
50,040 KB
testcase_09 AC 54 ms
50,164 KB
testcase_10 AC 53 ms
50,512 KB
testcase_11 AC 57 ms
50,156 KB
testcase_12 AC 54 ms
50,280 KB
testcase_13 AC 53 ms
50,008 KB
testcase_14 AC 53 ms
50,448 KB
testcase_15 AC 53 ms
50,004 KB
testcase_16 AC 53 ms
50,120 KB
testcase_17 AC 53 ms
50,548 KB
testcase_18 AC 55 ms
50,308 KB
testcase_19 AC 56 ms
50,236 KB
testcase_20 AC 54 ms
50,340 KB
testcase_21 AC 54 ms
50,260 KB
testcase_22 AC 53 ms
50,104 KB
testcase_23 AC 54 ms
49,900 KB
testcase_24 AC 53 ms
50,460 KB
testcase_25 AC 55 ms
50,152 KB
testcase_26 AC 53 ms
50,496 KB
testcase_27 AC 52 ms
50,372 KB
testcase_28 AC 53 ms
50,448 KB
testcase_29 AC 54 ms
50,176 KB
testcase_30 AC 58 ms
50,488 KB
testcase_31 AC 53 ms
50,412 KB
testcase_32 AC 57 ms
50,112 KB
testcase_33 AC 70 ms
51,056 KB
testcase_34 AC 70 ms
51,048 KB
testcase_35 AC 55 ms
50,452 KB
testcase_36 AC 53 ms
50,260 KB
testcase_37 AC 53 ms
50,428 KB
testcase_38 AC 54 ms
50,464 KB
testcase_39 AC 53 ms
50,392 KB
testcase_40 AC 59 ms
50,312 KB
testcase_41 AC 54 ms
50,120 KB
testcase_42 AC 55 ms
50,584 KB
testcase_43 AC 53 ms
50,424 KB
testcase_44 AC 53 ms
50,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.StringTokenizer;

public class Main {

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    void solve() throws IOException {
        long n = nl();

        if (n == 4) {
            out.println(4);
            return;
        }

        for (long i = 3; i * i <= n; i++) {
            if (n % i == 0) {
                out.println(i);
                return;
            }
        }

        out.println(n % 2 == 0 ? n / 2 : n);
    }

    String ns() throws IOException {
        while (!tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine(), " ");
        }
        return tok.nextToken();
    }

    int ni() throws IOException {
        return Integer.parseInt(ns());
    }

    long nl() throws IOException {
        return Long.parseLong(ns());
    }

    double nd() throws IOException {
        return Double.parseDouble(ns());
    }

    String[] nsa(int n) throws IOException {
        String[] res = new String[n];
        for (int i = 0; i < n; i++) {
            res[i] = ns();
        }
        return res;
    }

    int[] nia(int n) throws IOException {
        int[] res = new int[n];
        for (int i = 0; i < n; i++) {
            res[i] = ni();
        }
        return res;
    }

    long[] nla(int n) throws IOException {
        long[] res = new long[n];
        for (int i = 0; i < n; i++) {
            res[i] = nl();
        }
        return res;
    }

    public static void main(String[] args) throws IOException {
        in = new BufferedReader(new InputStreamReader(System.in));
        out = new PrintWriter(System.out);
        tok = new StringTokenizer("");
        Main main = new Main();
        main.solve();
        out.close();
    }
}
0