結果
問題 |
No.726 Tree Game
|
ユーザー |
![]() |
提出日時 | 2020-09-02 12:58:06 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 830 bytes |
コンパイル時間 | 2,194 ms |
コンパイル使用メモリ | 74,568 KB |
実行使用メモリ | 41,556 KB |
最終ジャッジ日時 | 2024-11-21 14:07:55 |
合計ジャッジ時間 | 6,536 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 16 WA * 9 |
ソースコード
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int y = sc.nextInt(); int x = sc.nextInt(); int nextY = y; while (!isPrime(nextY)) { nextY++; } int nextX = x; while (!isPrime(nextX)) { nextX++; } if (x == nextX || y == nextY) { System.out.println("First"); } else if ((nextX - x - 1 + nextY - y - 1) % 2 == 0) { System.out.println("Second"); } else { System.out.println("First"); } } static boolean isPrime(int x) { for (int i = 2; i <= Math.sqrt(x); i++) { if (x % i == 0) { return false; } } return true; } }