結果
問題 |
No.308 素数は通れません
|
ユーザー |
![]() |
提出日時 | 2015-12-07 04:17:46 |
言語 | Java (openjdk 23) |
結果 |
RE
|
実行時間 | - |
コード長 | 773 bytes |
コンパイル時間 | 2,444 ms |
コンパイル使用メモリ | 77,028 KB |
実行使用メモリ | 55,620 KB |
最終ジャッジ日時 | 2024-09-14 17:57:34 |
合計ジャッジ時間 | 19,143 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 90 RE * 17 |
ソースコード
import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); BigInteger n = new BigInteger(sc.next()); int[] num100 = {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,8,8,8,1,8,1,8,8,8,8,8,1,8,8,8,1,8,1,8,8,8,1,8,14,8,8,8,1,8,8,8,8,8,1,8,1,8,8,8,8,8,1,8,8,8,1,8,1,8,8,8,8,8,1,8,14,8,1,8,8,8,8,8,1,8,8,8,8,8,8,8,1,8,8}; if(n.intValue() < 100){ System.out.println(num100[n.intValue()-1]); }else{ if(n.mod(BigInteger.valueOf(8)).intValue() != 1){ System.out.println(8); }else{ BigInteger m = n.subtract(BigInteger.valueOf(8)); if(m.isProbablePrime(50)){ System.out.println(14); }else{ System.out.println(8); } } } } }