結果

問題 No.192 合成数
ユーザー jimanojimano
提出日時 2016-01-10 12:42:47
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 2,000 ms
コード長 557 bytes
コンパイル時間 3,558 ms
コンパイル使用メモリ 74,644 KB
実行使用メモリ 41,340 KB
最終ジャッジ日時 2024-06-27 01:53:43
合計ジャッジ時間 7,584 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
41,268 KB
testcase_01 AC 123 ms
41,120 KB
testcase_02 AC 122 ms
39,976 KB
testcase_03 AC 122 ms
41,192 KB
testcase_04 AC 124 ms
41,236 KB
testcase_05 AC 112 ms
39,780 KB
testcase_06 AC 119 ms
41,072 KB
testcase_07 AC 124 ms
41,192 KB
testcase_08 AC 123 ms
41,232 KB
testcase_09 AC 123 ms
41,176 KB
testcase_10 AC 124 ms
41,340 KB
testcase_11 AC 126 ms
41,120 KB
testcase_12 AC 128 ms
41,044 KB
testcase_13 AC 120 ms
40,288 KB
testcase_14 AC 119 ms
39,844 KB
testcase_15 AC 125 ms
41,060 KB
testcase_16 AC 124 ms
41,256 KB
testcase_17 AC 122 ms
41,208 KB
testcase_18 AC 125 ms
41,116 KB
testcase_19 AC 125 ms
41,160 KB
testcase_20 AC 123 ms
41,192 KB
testcase_21 AC 111 ms
40,036 KB
testcase_22 AC 122 ms
41,052 KB
testcase_23 AC 119 ms
41,176 KB
testcase_24 AC 120 ms
41,084 KB
testcase_25 AC 111 ms
40,036 KB
testcase_26 AC 110 ms
40,188 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No0192 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int min = N - 100;
		int max = N + 100;
		int ans = 0;
		
		if(isComposite(N)){
			ans = N;
		}
		else{
			for(int i = min; i < (max + 1); i++){
				if(isComposite(i)) {
					ans = i;
					break;
				}
			}
		}
		System.out.println(ans);
	}
	
	static boolean isComposite(int num){
		
		if(num < 3) return false;
		for(int i = 2; i < num; i++){
			if(num % i == 0) return true;
		}
		return false;
	}
}
0