結果
問題 | No.308 素数は通れません |
ユーザー |
![]() |
提出日時 | 2015-12-02 17:42:46 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 175 ms / 1,000 ms |
コード長 | 640 bytes |
コンパイル時間 | 2,197 ms |
コンパイル使用メモリ | 74,500 KB |
実行使用メモリ | 42,828 KB |
最終ジャッジ日時 | 2024-11-27 18:32:04 |
合計ジャッジ時間 | 19,963 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 107 |
ソースコード
// Probable......import java.util.Scanner;import java.math.BigInteger;public class Main {public static void main(String[] args) {int[] a = {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};Scanner sc = new Scanner(System.in);BigInteger n = sc.nextBigInteger();int v;if( n.compareTo(new BigInteger("26")) < 0 ) {v = a[ (int) n.longValue() ];} else {if(n.mod(new BigInteger("8")).compareTo(BigInteger.ONE) == 0 &&n.subtract(new BigInteger("8")).isProbablePrime(80)){v = 14;} else {v = 8;}}System.out.println(v);}}