結果

問題 No.192 合成数
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-12 00:33:26
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 610 bytes
コンパイル時間 2,130 ms
コンパイル使用メモリ 74,556 KB
実行使用メモリ 53,996 KB
最終ジャッジ日時 2024-05-01 11:34:38
合計ジャッジ時間 7,441 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
41,328 KB
testcase_01 AC 133 ms
41,444 KB
testcase_02 AC 135 ms
41,320 KB
testcase_03 AC 132 ms
41,380 KB
testcase_04 AC 132 ms
41,208 KB
testcase_05 AC 134 ms
41,588 KB
testcase_06 AC 138 ms
41,684 KB
testcase_07 AC 134 ms
41,228 KB
testcase_08 AC 137 ms
41,252 KB
testcase_09 AC 138 ms
41,632 KB
testcase_10 AC 118 ms
40,188 KB
testcase_11 AC 133 ms
41,140 KB
testcase_12 AC 136 ms
41,444 KB
testcase_13 AC 120 ms
40,240 KB
testcase_14 AC 141 ms
41,544 KB
testcase_15 AC 134 ms
41,392 KB
testcase_16 AC 133 ms
41,344 KB
testcase_17 AC 132 ms
41,100 KB
testcase_18 AC 133 ms
41,508 KB
testcase_19 AC 118 ms
39,860 KB
testcase_20 AC 133 ms
41,252 KB
testcase_21 AC 133 ms
41,380 KB
testcase_22 AC 120 ms
40,200 KB
testcase_23 WA -
testcase_24 AC 133 ms
41,448 KB
testcase_25 AC 136 ms
41,396 KB
testcase_26 AC 133 ms
41,392 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);
	public static void main(String[] args) {
		int n = sc.nextInt();
		int a = n-100;
		int b = n+100;
		for (int i=a; i<=b; i++) {
			boolean boo = isPrime(i);
			if (boo==false) {System.out.println(i); break;}
		}
	}
	public static boolean isPrime(int num) {
	    if (num < 2) return false;
	    else if (num == 2) return true;
	    else if (num % 2 == 0) return false;
	    double sqrtNum = Math.sqrt(num);
	    for (int i = 3; i <= sqrtNum; i += 2) {
	        if (num % i == 0) {return false;}
	    }
	    return true;
	}
}
0