結果

問題 No.8023 素数判定するだけ
コンテスト
ユーザー kzyKT
提出日時 2017-03-31 22:46:59
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
WA  
実行時間 -
コード長 696 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,565 ms
コンパイル使用メモリ 82,576 KB
実行使用メモリ 43,304 KB
最終ジャッジ日時 2026-03-28 19:40:23
合計ジャッジ時間 5,711 ms
ジャッジサーバーID
(参考情報)
judge2_1 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other WA * 25
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.io.*;
import java.lang.*;
import java.util.*;
import java.math.*;

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");
    }
}
0