結果
問題 |
No.726 Tree Game
|
ユーザー |
![]() |
提出日時 | 2020-09-02 12:59:08 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 888 bytes |
コンパイル時間 | 2,222 ms |
コンパイル使用メモリ | 78,512 KB |
実行使用メモリ | 41,616 KB |
最終ジャッジ日時 | 2024-11-21 14:08:01 |
合計ジャッジ時間 | 6,424 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 19 WA * 6 |
ソースコード
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) { if (x == 1) { return false; } for (int i = 2; i <= Math.sqrt(x); i++) { if (x % i == 0) { return false; } } return true; } }