結果

問題 No.3023 素数判定するだけ
ユーザー tanzakutanzaku
提出日時 2017-03-31 22:50:05
言語 Java19
(openjdk 21)
結果
AC  
実行時間 133 ms / 1,000 ms
コード長 533 bytes
コンパイル時間 4,174 ms
コンパイル使用メモリ 73,176 KB
実行使用メモリ 56,536 KB
最終ジャッジ日時 2023-07-27 19:37:05
合計ジャッジ時間 10,200 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 128 ms
56,168 KB
testcase_01 AC 125 ms
55,744 KB
testcase_02 AC 125 ms
55,836 KB
testcase_03 AC 124 ms
55,908 KB
testcase_04 AC 124 ms
55,912 KB
testcase_05 AC 126 ms
55,588 KB
testcase_06 AC 126 ms
55,716 KB
testcase_07 AC 124 ms
55,796 KB
testcase_08 AC 126 ms
56,084 KB
testcase_09 AC 125 ms
55,828 KB
testcase_10 AC 126 ms
55,704 KB
testcase_11 AC 124 ms
55,900 KB
testcase_12 AC 125 ms
56,108 KB
testcase_13 AC 126 ms
55,648 KB
testcase_14 AC 131 ms
55,768 KB
testcase_15 AC 124 ms
55,716 KB
testcase_16 AC 127 ms
56,536 KB
testcase_17 AC 133 ms
55,472 KB
testcase_18 AC 123 ms
55,684 KB
testcase_19 AC 122 ms
55,944 KB
testcase_20 AC 125 ms
55,480 KB
testcase_21 AC 126 ms
56,056 KB
testcase_22 AC 126 ms
55,872 KB
testcase_23 AC 125 ms
56,040 KB
testcase_24 AC 124 ms
56,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class yuki {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		BigInteger b = sc.nextBigInteger();
		for (BigInteger i = BigInteger.ONE.add(BigInteger.ONE); i.compareTo(b) < BigInteger.ZERO.intValue(); i = i.add(BigInteger.ONE)) {
			if (b.mod(i).equals(BigInteger.ZERO)) {
				System.out.println("NO");
				return;
			}
		}
		if (b.equals(BigInteger.ONE)) {
			System.out.println("NO");
			return;
		}
		System.out.println("YES");
	}
}
0