結果

問題 No.3023 素数判定するだけ
ユーザー 37zigen37zigen
提出日時 2017-03-31 23:01:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 1,000 ms
コード長 699 bytes
コンパイル時間 2,188 ms
コンパイル使用メモリ 75,300 KB
実行使用メモリ 54,272 KB
最終ジャッジ日時 2024-04-15 06:26:31
合計ジャッジ時間 8,331 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 122 ms
54,192 KB
testcase_01 AC 111 ms
52,884 KB
testcase_02 AC 124 ms
54,224 KB
testcase_03 AC 124 ms
53,880 KB
testcase_04 AC 121 ms
54,164 KB
testcase_05 AC 123 ms
54,184 KB
testcase_06 AC 110 ms
53,580 KB
testcase_07 AC 116 ms
53,772 KB
testcase_08 AC 120 ms
53,728 KB
testcase_09 AC 122 ms
54,152 KB
testcase_10 AC 117 ms
53,876 KB
testcase_11 AC 121 ms
54,272 KB
testcase_12 AC 124 ms
54,008 KB
testcase_13 AC 112 ms
53,084 KB
testcase_14 AC 112 ms
53,132 KB
testcase_15 AC 118 ms
53,964 KB
testcase_16 AC 105 ms
52,496 KB
testcase_17 AC 107 ms
52,976 KB
testcase_18 AC 117 ms
54,020 KB
testcase_19 AC 108 ms
53,064 KB
testcase_20 AC 104 ms
52,824 KB
testcase_21 AC 120 ms
53,884 KB
testcase_22 AC 121 ms
54,016 KB
testcase_23 AC 115 ms
53,976 KB
testcase_24 AC 107 ms
53,076 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		if (N == BigInteger.ONE.intValue()) {
			System.out.println("NO");
			return;
		}
		for (int i = BigInteger.ONE.add(BigInteger.ONE).intValue(); i < N; i = BigInteger.valueOf(i).add(BigInteger.ONE)
				.intValue()) {
			if (N % i == BigInteger.ZERO.intValue()) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}

	void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
}
0