結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
54,280 KB
testcase_01 AC 130 ms
53,960 KB
testcase_02 AC 128 ms
54,144 KB
testcase_03 AC 127 ms
54,080 KB
testcase_04 AC 126 ms
54,212 KB
testcase_05 AC 128 ms
53,968 KB
testcase_06 AC 127 ms
53,876 KB
testcase_07 AC 130 ms
53,864 KB
testcase_08 AC 131 ms
54,028 KB
testcase_09 AC 127 ms
54,144 KB
testcase_10 AC 130 ms
54,260 KB
testcase_11 AC 134 ms
54,216 KB
testcase_12 AC 131 ms
54,268 KB
testcase_13 AC 130 ms
54,264 KB
testcase_14 AC 132 ms
54,108 KB
testcase_15 AC 129 ms
54,160 KB
testcase_16 AC 134 ms
54,008 KB
testcase_17 AC 132 ms
54,400 KB
testcase_18 AC 134 ms
54,012 KB
testcase_19 AC 130 ms
54,480 KB
testcase_20 AC 130 ms
54,200 KB
testcase_21 AC 130 ms
53,944 KB
testcase_22 AC 130 ms
54,264 KB
testcase_23 AC 129 ms
54,276 KB
testcase_24 AC 131 ms
53,964 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