結果

問題 No.312 置換処理
ユーザー jp_stejp_ste
提出日時 2016-02-02 21:34:23
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 815 bytes
コンパイル時間 2,137 ms
コンパイル使用メモリ 77,480 KB
実行使用メモリ 57,760 KB
最終ジャッジ日時 2023-10-21 18:45:20
合計ジャッジ時間 9,789 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 144 ms
57,084 KB
testcase_02 AC 152 ms
57,452 KB
testcase_03 AC 153 ms
57,436 KB
testcase_04 AC 131 ms
57,360 KB
testcase_05 AC 148 ms
57,760 KB
testcase_06 AC 148 ms
57,560 KB
testcase_07 AC 151 ms
57,404 KB
testcase_08 AC 149 ms
57,440 KB
testcase_09 AC 148 ms
57,428 KB
testcase_10 AC 146 ms
57,044 KB
testcase_11 AC 147 ms
57,384 KB
testcase_12 AC 147 ms
55,688 KB
testcase_13 AC 132 ms
57,028 KB
testcase_14 AC 132 ms
57,028 KB
testcase_15 AC 131 ms
57,432 KB
testcase_16 AC 132 ms
57,280 KB
testcase_17 AC 131 ms
57,256 KB
testcase_18 AC 133 ms
57,296 KB
testcase_19 AC 131 ms
57,520 KB
testcase_20 AC 132 ms
57,336 KB
testcase_21 AC 130 ms
57,328 KB
testcase_22 AC 132 ms
57,032 KB
testcase_23 AC 133 ms
56,964 KB
testcase_24 AC 132 ms
57,324 KB
testcase_25 AC 134 ms
57,280 KB
testcase_26 AC 133 ms
57,464 KB
testcase_27 AC 132 ms
57,260 KB
testcase_28 AC 131 ms
57,332 KB
testcase_29 AC 130 ms
57,304 KB
testcase_30 AC 147 ms
57,320 KB
testcase_31 AC 130 ms
57,356 KB
testcase_32 AC 143 ms
57,256 KB
testcase_33 AC 148 ms
57,376 KB
testcase_34 AC 149 ms
57,100 KB
testcase_35 AC 147 ms
57,544 KB
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 132 ms
57,364 KB
testcase_39 AC 145 ms
57,480 KB
testcase_40 AC 155 ms
57,056 KB
testcase_41 AC 130 ms
57,364 KB
testcase_42 AC 137 ms
56,964 KB
testcase_43 AC 130 ms
57,392 KB
testcase_44 AC 130 ms
57,516 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		long N = scan.nextLong();

		if(N % 4 == 0) {
			System.out.println(4);
			
		} else {
		 
			int M = (int)Math.sqrt(N);
			boolean primeList[] = new boolean[M+1];
			for(int i=2; i<=M; i++) {
				primeList[i] = true;
			}
			
			for(int i=2; i<=M; i++) {
				if(primeList[i]) {
					for(int j=i+i; j<=M; j=j+i) {
						primeList[j] = false;
					}
				}
			}
			
			boolean find = false;
			int i;
			for(i=3; i<=M; i++) {
				if(primeList[i]) {
					if(N%i == 0) {
						find = true;
						break;
					}
				}
			}
			if(find) {
				System.out.println(i);
			} else {
				if(N % 2 == 0) {
					System.out.println(N/2);
				} else {
					System.out.println(N);
				}
			}
		} 
	}
}
0