結果

問題 No.3023 素数判定するだけ
ユーザー kzyKTkzyKT
提出日時 2017-03-31 22:50:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 1,000 ms
コード長 699 bytes
コンパイル時間 2,091 ms
コンパイル使用メモリ 75,240 KB
実行使用メモリ 54,476 KB
最終ジャッジ日時 2024-04-15 06:24:54
合計ジャッジ時間 8,974 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
54,160 KB
testcase_01 AC 128 ms
54,264 KB
testcase_02 AC 125 ms
54,112 KB
testcase_03 AC 123 ms
54,156 KB
testcase_04 AC 122 ms
54,136 KB
testcase_05 AC 126 ms
54,072 KB
testcase_06 AC 124 ms
54,476 KB
testcase_07 AC 126 ms
54,224 KB
testcase_08 AC 126 ms
54,204 KB
testcase_09 AC 126 ms
53,896 KB
testcase_10 AC 126 ms
53,988 KB
testcase_11 AC 128 ms
54,136 KB
testcase_12 AC 130 ms
54,288 KB
testcase_13 AC 131 ms
54,156 KB
testcase_14 AC 132 ms
54,320 KB
testcase_15 AC 127 ms
54,376 KB
testcase_16 AC 131 ms
54,040 KB
testcase_17 AC 137 ms
54,328 KB
testcase_18 AC 128 ms
54,256 KB
testcase_19 AC 124 ms
54,236 KB
testcase_20 AC 125 ms
54,220 KB
testcase_21 AC 124 ms
54,064 KB
testcase_22 AC 126 ms
53,988 KB
testcase_23 AC 127 ms
53,972 KB
testcase_24 AC 127 ms
53,912 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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