結果
| 問題 | 
                            No.726 Tree Game
                             | 
                    
| コンテスト | |
| ユーザー | 
                             tenten
                         | 
                    
| 提出日時 | 2020-09-02 12:57:19 | 
| 言語 | Java  (openjdk 23)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 830 bytes | 
| コンパイル時間 | 1,959 ms | 
| コンパイル使用メモリ | 74,616 KB | 
| 実行使用メモリ | 56,104 KB | 
| 最終ジャッジ日時 | 2024-11-21 14:07:48 | 
| 合計ジャッジ時間 | 6,048 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | WA * 25 | 
ソースコード
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