結果

問題 No.3023 素数判定するだけ
ユーザー fal_rndfal_rnd
提出日時 2017-03-31 22:44:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 1,000 ms
コード長 616 bytes
コンパイル時間 2,496 ms
コンパイル使用メモリ 75,056 KB
実行使用メモリ 55,972 KB
最終ジャッジ日時 2024-04-15 06:23:14
合計ジャッジ時間 8,049 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
54,212 KB
testcase_01 AC 105 ms
52,940 KB
testcase_02 AC 108 ms
52,624 KB
testcase_03 AC 109 ms
53,128 KB
testcase_04 AC 125 ms
54,312 KB
testcase_05 AC 117 ms
55,972 KB
testcase_06 AC 109 ms
54,052 KB
testcase_07 AC 117 ms
54,136 KB
testcase_08 AC 109 ms
53,196 KB
testcase_09 AC 117 ms
53,992 KB
testcase_10 AC 109 ms
53,192 KB
testcase_11 AC 107 ms
52,780 KB
testcase_12 AC 121 ms
54,532 KB
testcase_13 AC 111 ms
52,892 KB
testcase_14 AC 123 ms
54,688 KB
testcase_15 AC 107 ms
52,896 KB
testcase_16 AC 110 ms
53,188 KB
testcase_17 AC 127 ms
54,196 KB
testcase_18 AC 119 ms
54,224 KB
testcase_19 AC 117 ms
54,148 KB
testcase_20 AC 115 ms
54,096 KB
testcase_21 AC 120 ms
54,092 KB
testcase_22 AC 115 ms
54,056 KB
testcase_23 AC 108 ms
53,152 KB
testcase_24 AC 121 ms
54,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main{

	static Scanner s=new Scanner(System.in);

	public static void main(String __[]){
		input();
		solve(s.nextInt());
	}

	private static void input(){
	}

	private static void solve(int in){
		BigInteger inb=BigInteger.valueOf(in);
		if(inb.equals(BigInteger.ONE)){
			System.out.println("NO");
			return;
		}
		for(BigInteger bi=BigInteger.ONE.add(BigInteger.ONE); bi.intValue()<in; bi=bi.add(BigInteger.ONE)){
			if(inb.mod(bi).equals(BigInteger.ZERO)) {
				System.out.println("NO");
				return;
			}
		}
		System.out.println("YES");
	}
}
0