結果
| 問題 |
No.8023 素数判定するだけ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-03-31 22:50:58 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 119 ms / 1,000 ms |
| コード長 | 699 bytes |
| コンパイル時間 | 1,814 ms |
| コンパイル使用メモリ | 75,592 KB |
| 実行使用メモリ | 54,296 KB |
| 最終ジャッジ日時 | 2024-10-04 19:57:49 |
| 合計ジャッジ時間 | 7,473 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
import java.lang.Object;
import java.util.Scanner;
import java.math.BigInteger;
public class Main {
static Scanner cin = new Scanner(System.in);
public static void main(String[] args) {
BigInteger n = new BigInteger(cin.next());
BigInteger i = BigInteger.ONE;
i=i.add(BigInteger.ONE);
BigInteger f = BigInteger.ONE;
if(n.equals(BigInteger.ONE)) f=BigInteger.ZERO;
for(;; i=i.add(BigInteger.ONE)) {
if(i.equals(n)||f.equals(BigInteger.ZERO)) break;
if(n.mod(i)==BigInteger.ZERO) f=BigInteger.ZERO;
}
if(f.equals(BigInteger.ONE)) System.out.println("YES");
else System.out.println("NO");
}
}