結果

問題 No.312 置換処理
ユーザー shinwisteriashinwisteria
提出日時 2017-04-01 21:27:19
言語 Java21
(openjdk 21)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 687 bytes
コンパイル時間 3,581 ms
コンパイル使用メモリ 72,104 KB
実行使用メモリ 62,168 KB
最終ジャッジ日時 2023-08-09 16:04:26
合計ジャッジ時間 10,926 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
58,004 KB
testcase_01 AC 143 ms
57,732 KB
testcase_02 AC 147 ms
59,552 KB
testcase_03 AC 147 ms
59,968 KB
testcase_04 AC 129 ms
55,728 KB
testcase_05 AC 134 ms
59,756 KB
testcase_06 AC 139 ms
57,456 KB
testcase_07 AC 144 ms
58,028 KB
testcase_08 AC 141 ms
58,096 KB
testcase_09 AC 139 ms
57,428 KB
testcase_10 AC 136 ms
57,640 KB
testcase_11 AC 140 ms
58,200 KB
testcase_12 AC 134 ms
57,636 KB
testcase_13 AC 135 ms
58,136 KB
testcase_14 AC 132 ms
57,640 KB
testcase_15 AC 132 ms
57,732 KB
testcase_16 AC 135 ms
57,996 KB
testcase_17 AC 135 ms
58,224 KB
testcase_18 AC 135 ms
57,720 KB
testcase_19 AC 136 ms
58,136 KB
testcase_20 AC 137 ms
58,172 KB
testcase_21 AC 137 ms
62,168 KB
testcase_22 AC 122 ms
55,672 KB
testcase_23 AC 125 ms
55,628 KB
testcase_24 AC 122 ms
55,376 KB
testcase_25 AC 120 ms
55,748 KB
testcase_26 AC 122 ms
55,404 KB
testcase_27 AC 121 ms
55,740 KB
testcase_28 AC 121 ms
55,976 KB
testcase_29 AC 123 ms
55,584 KB
testcase_30 AC 129 ms
55,984 KB
testcase_31 AC 129 ms
55,556 KB
testcase_32 AC 130 ms
55,908 KB
testcase_33 AC 137 ms
57,644 KB
testcase_34 AC 138 ms
59,564 KB
testcase_35 AC 132 ms
57,716 KB
testcase_36 AC 117 ms
55,400 KB
testcase_37 AC 119 ms
55,628 KB
testcase_38 AC 122 ms
56,224 KB
testcase_39 AC 128 ms
57,716 KB
testcase_40 AC 122 ms
55,380 KB
testcase_41 AC 122 ms
55,668 KB
testcase_42 AC 122 ms
55,948 KB
testcase_43 AC 121 ms
55,736 KB
testcase_44 AC 120 ms
55,600 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Chikanshori {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner s = new Scanner(System.in);
		long N = s.nextLong();
		s.close();
		boolean tof = true;
		int root = (int)Math.sqrt(N);
		if(N % 3 != 0 &&N % 4 == 0){
			N = 4;
		}else if(N % 2 == 0){
			N /= 2;
		}
		
		int[] prime = new int[root+1];
		prime[0] = 1;
		prime[1] = 1;
		for(int i = 3;i <=root;i++){
			if(prime[i] == 0){
				for(int j = 1;j*i <= root;j++){
					prime[j*i] = 1;
				}
				if(N % i == 0){
					System.out.println(i);
					tof = false;
					break;
				}
			}
		}
		if(tof){
			System.out.println(N);
		}

	}

}
0