結果
問題 |
No.726 Tree Game
|
ユーザー |
![]() |
提出日時 | 2018-08-24 21:49:37 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 743 bytes |
コンパイル時間 | 2,689 ms |
コンパイル使用メモリ | 77,740 KB |
実行使用メモリ | 41,368 KB |
最終ジャッジ日時 | 2024-06-23 07:05:08 |
合計ジャッジ時間 | 6,694 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 23 WA * 2 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); long Y = scan.nextLong(); long X = scan.nextLong(); scan.close(); long pX = X + 1; long pY = Y + 1; while(!isPrime(pX)) { pX ++; } while(!isPrime(pY)) { pY ++; } long k = pX - X + pY - Y - 2; if(k % 2 == 0) { System.out.println("Second"); }else { System.out.println("First"); } } public static boolean isPrime(long n) { if(n < 2) return false; if(n == 2) return true; if(n % 2 == 0) return false; for(long i = 3; i <= (long)Math.sqrt(n); i += 2){ if(n % i == 0) { return false; } } return true; } }