結果
| 問題 |
No.308 素数は通れません
|
| コンテスト | |
| ユーザー |
piyoko_212
|
| 提出日時 | 2015-12-25 19:05:17 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 178 ms / 1,000 ms |
| コード長 | 703 bytes |
| コンパイル時間 | 2,420 ms |
| コンパイル使用メモリ | 77,220 KB |
| 実行使用メモリ | 54,504 KB |
| 最終ジャッジ日時 | 2024-11-27 18:46:03 |
| 合計ジャッジ時間 | 20,088 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 107 |
ソースコード
import java.util.*;
import java.math.*;
class Main{
static int small[]={0,0,0,0,3,0,5,0,7,7,7,0,11,0,13,7,7,0,8,0,19,19,7,0,23,23};
public static void main(String[] args){
Scanner s=new Scanner(System.in);
BigInteger bi=s.nextBigInteger();
if(bi.compareTo(new BigInteger("26"))==-1){
System.out.println(small[bi.intValue()]);
System.exit(0);
}
if(bi.mod(new BigInteger("8")).equals(BigInteger.ONE)&&bi.subtract(new BigInteger("8")).isProbablePrime(100)){
if(bi.mod(new BigInteger("14")).equals(BigInteger.ONE)&&bi.subtract(new BigInteger("14")).isProbablePrime(100)){
System.out.println(17);
}else{
System.out.println(14);
}
}else{
System.out.println(8);
}
}
}
piyoko_212