結果

問題 No.308 素数は通れません
ユーザー Nekosyndrome
提出日時 2015-12-12 03:37:16
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 587 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 74,260 KB
実行使用メモリ 54,680 KB
最終ジャッジ日時 2024-09-15 08:36:03
合計ジャッジ時間 18,294 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 78 WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;

class main
{
	public static BigInteger trans(int x)
	{
		return BigInteger.valueOf(x);
	}
	public static void main(String[] args)
	{
		int []ans={-1,-1,-1,-1,3,-1,5,-1,7,7,7,-1,11,-1,13,7,7,-1,8,-1,19,19,7,-1,23,23};
		Scanner sc = new Scanner(System.in);
		BigInteger n = sc.nextBigInteger();

		if(n.compareTo( trans(25) )<=0)
			System.out.println(ans[n.intValue()]);
		else
		{
			if( n.mod(trans(8)).compareTo(trans(1))==1 && n.subtract(trans(8)).isProbablePrime(20) )
				System.out.println(14);
			else
				System.out.println(8);
		}
	}
}
0