結果

問題 No.312 置換処理
ユーザー jp_stejp_ste
提出日時 2016-02-02 21:46:00
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 741 bytes
コンパイル時間 2,259 ms
コンパイル使用メモリ 74,332 KB
実行使用メモリ 57,748 KB
最終ジャッジ日時 2023-10-21 18:46:08
合計ジャッジ時間 9,537 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
57,360 KB
testcase_01 AC 135 ms
57,416 KB
testcase_02 AC 132 ms
57,380 KB
testcase_03 AC 131 ms
57,504 KB
testcase_04 AC 130 ms
57,364 KB
testcase_05 AC 132 ms
57,384 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 136 ms
57,324 KB
testcase_09 AC 133 ms
57,452 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 128 ms
57,372 KB
testcase_13 AC 131 ms
57,356 KB
testcase_14 AC 132 ms
57,372 KB
testcase_15 AC 133 ms
57,396 KB
testcase_16 AC 132 ms
57,344 KB
testcase_17 AC 131 ms
57,332 KB
testcase_18 AC 133 ms
57,356 KB
testcase_19 AC 132 ms
57,384 KB
testcase_20 AC 136 ms
57,468 KB
testcase_21 AC 132 ms
57,448 KB
testcase_22 AC 130 ms
57,560 KB
testcase_23 AC 130 ms
57,452 KB
testcase_24 AC 133 ms
57,488 KB
testcase_25 AC 133 ms
57,208 KB
testcase_26 AC 133 ms
57,376 KB
testcase_27 AC 135 ms
57,488 KB
testcase_28 AC 135 ms
57,356 KB
testcase_29 AC 130 ms
57,280 KB
testcase_30 AC 130 ms
57,496 KB
testcase_31 AC 129 ms
55,552 KB
testcase_32 AC 126 ms
57,368 KB
testcase_33 AC 134 ms
57,380 KB
testcase_34 AC 132 ms
57,436 KB
testcase_35 WA -
testcase_36 AC 132 ms
57,372 KB
testcase_37 AC 129 ms
57,492 KB
testcase_38 AC 128 ms
57,336 KB
testcase_39 AC 128 ms
57,312 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 133 ms
57,384 KB
testcase_43 AC 132 ms
57,040 KB
testcase_44 AC 131 ms
57,336 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();

		int M = (int)Math.sqrt(100000L);
		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;
				}
			}
		}
		primeList[4] = true;
		
		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