結果
| 問題 |
No.8023 素数判定するだけ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-31 23:01:37 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 124 ms / 1,000 ms |
| コード長 | 699 bytes |
| コンパイル時間 | 2,100 ms |
| コンパイル使用メモリ | 76,832 KB |
| 実行使用メモリ | 54,356 KB |
| 最終ジャッジ日時 | 2024-10-04 20:00:58 |
| 合計ジャッジ時間 | 7,959 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
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));
}
}