結果

問題 No.726 Tree Game
ユーザー YamaKasaYamaKasa
提出日時 2018-08-24 21:43:06
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 735 bytes
コンパイル時間 3,517 ms
コンパイル使用メモリ 72,112 KB
実行使用メモリ 58,064 KB
最終ジャッジ日時 2023-09-05 11:18:27
合計ジャッジ時間 7,995 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
58,064 KB
testcase_01 AC 123 ms
56,160 KB
testcase_02 AC 129 ms
55,820 KB
testcase_03 AC 130 ms
55,796 KB
testcase_04 AC 131 ms
55,788 KB
testcase_05 AC 131 ms
56,024 KB
testcase_06 AC 131 ms
55,848 KB
testcase_07 WA -
testcase_08 AC 129 ms
55,552 KB
testcase_09 WA -
testcase_10 AC 132 ms
55,792 KB
testcase_11 AC 128 ms
55,532 KB
testcase_12 AC 129 ms
55,532 KB
testcase_13 AC 128 ms
55,848 KB
testcase_14 AC 130 ms
55,708 KB
testcase_15 AC 131 ms
55,916 KB
testcase_16 AC 130 ms
56,076 KB
testcase_17 AC 131 ms
55,812 KB
testcase_18 AC 132 ms
55,816 KB
testcase_19 AC 130 ms
55,984 KB
testcase_20 AC 132 ms
56,148 KB
testcase_21 AC 131 ms
55,528 KB
testcase_22 AC 134 ms
55,776 KB
testcase_23 AC 129 ms
56,076 KB
testcase_24 AC 130 ms
55,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int Y = scan.nextInt();
		int X = scan.nextInt();
		scan.close();
		int pX = X + 1;
		int pY = Y + 1;
		while(!isPrime(pX)) {
			pX ++;
		}
		while(!isPrime(pY)) {
			pY ++;
		}
		int 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 <= (int)Math.sqrt(n); i += 2){
            if(n % i == 0) {
                return false;
            }
        }
        return true;
    }
}
0