結果
| 問題 | No.726 Tree Game |
| コンテスト | |
| ユーザー |
tenten
|
| 提出日時 | 2020-09-02 12:58:06 |
| 言語 | Java (openjdk 26.0.2.1 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 830 bytes |
| 記録 | |
| コンパイル時間 | 1,633 ms |
| コンパイル使用メモリ | 85,476 KB |
| 実行使用メモリ | 45,356 KB |
| 最終ジャッジ日時 | 2026-09-27 13:50:24 |
| 合計ジャッジ時間 | 4,396 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}
}
tenten