結果

問題 No.312 置換処理
ユーザー kenji_shioyakenji_shioya
提出日時 2016-06-10 01:38:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 746 bytes
コンパイル時間 3,619 ms
コンパイル使用メモリ 74,924 KB
実行使用メモリ 51,068 KB
最終ジャッジ日時 2024-04-27 10:45:53
合計ジャッジ時間 7,097 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
50,000 KB
testcase_01 AC 73 ms
50,808 KB
testcase_02 AC 77 ms
51,068 KB
testcase_03 AC 78 ms
50,780 KB
testcase_04 AC 54 ms
49,860 KB
testcase_05 AC 54 ms
50,200 KB
testcase_06 AC 58 ms
50,092 KB
testcase_07 AC 66 ms
50,536 KB
testcase_08 AC 55 ms
50,240 KB
testcase_09 AC 58 ms
50,184 KB
testcase_10 AC 58 ms
50,144 KB
testcase_11 AC 61 ms
49,896 KB
testcase_12 AC 58 ms
50,056 KB
testcase_13 AC 57 ms
50,220 KB
testcase_14 AC 61 ms
50,316 KB
testcase_15 AC 59 ms
50,332 KB
testcase_16 AC 53 ms
50,284 KB
testcase_17 AC 56 ms
50,060 KB
testcase_18 AC 56 ms
49,984 KB
testcase_19 AC 58 ms
50,236 KB
testcase_20 AC 57 ms
49,968 KB
testcase_21 AC 54 ms
50,260 KB
testcase_22 AC 53 ms
50,248 KB
testcase_23 AC 55 ms
50,380 KB
testcase_24 AC 54 ms
50,140 KB
testcase_25 AC 55 ms
50,248 KB
testcase_26 AC 53 ms
49,968 KB
testcase_27 AC 54 ms
50,332 KB
testcase_28 AC 54 ms
50,300 KB
testcase_29 AC 55 ms
49,980 KB
testcase_30 AC 59 ms
50,216 KB
testcase_31 AC 57 ms
50,056 KB
testcase_32 AC 57 ms
50,192 KB
testcase_33 AC 65 ms
50,432 KB
testcase_34 AC 65 ms
50,624 KB
testcase_35 AC 54 ms
50,252 KB
testcase_36 AC 53 ms
50,148 KB
testcase_37 AC 53 ms
50,324 KB
testcase_38 AC 53 ms
50,236 KB
testcase_39 AC 52 ms
50,140 KB
testcase_40 AC 54 ms
49,844 KB
testcase_41 AC 55 ms
50,048 KB
testcase_42 AC 55 ms
50,148 KB
testcase_43 AC 55 ms
50,268 KB
testcase_44 AC 53 ms
50,264 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.io.*;

public class Exercise75{
  public static void main (String[] args) throws IOException{

    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String nStr = new String(in.readLine());

    long nd = Long.parseLong(nStr);
    long n = nd;

    long[] factor = new long[20];
    int count = 0;



    for (long i = 3; i * i <= n; i ++){
      if(n % i == 0){
        while (n % i == 0){
          factor[count] = i;
          n /= i;
        }
        count++;
      }
    }

    if (factor[0] > 2){
      System.out.println(factor[0]);
    }else{
      if(n % 2 == 0 && n / 2 != 2){
        System.out.println(n / 2);
      }else{
        System.out.println(n);
      }
    }
  }
}
0