結果

問題 No.726 Tree Game
ユーザー YamaKasaYamaKasa
提出日時 2018-08-24 21:57:12
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 832 bytes
コンパイル時間 3,484 ms
コンパイル使用メモリ 72,988 KB
実行使用メモリ 57,844 KB
最終ジャッジ日時 2023-09-05 11:39:31
合計ジャッジ時間 6,348 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
55,780 KB
testcase_01 AC 124 ms
55,760 KB
testcase_02 AC 125 ms
55,568 KB
testcase_03 AC 123 ms
55,996 KB
testcase_04 AC 123 ms
56,168 KB
testcase_05 AC 122 ms
56,076 KB
testcase_06 AC 123 ms
57,844 KB
testcase_07 AC 123 ms
55,572 KB
testcase_08 AC 126 ms
56,008 KB
testcase_09 WA -
testcase_10 AC 123 ms
55,816 KB
testcase_11 AC 122 ms
55,672 KB
testcase_12 AC 125 ms
55,568 KB
testcase_13 AC 128 ms
55,464 KB
testcase_14 AC 129 ms
55,540 KB
testcase_15 AC 125 ms
55,708 KB
testcase_16 AC 125 ms
56,152 KB
testcase_17 AC 124 ms
55,764 KB
testcase_18 AC 128 ms
55,828 KB
testcase_19 AC 127 ms
55,984 KB
testcase_20 AC 130 ms
55,988 KB
testcase_21 AC 127 ms
55,824 KB
testcase_22 AC 124 ms
56,020 KB
testcase_23 AC 125 ms
55,564 KB
testcase_24 AC 125 ms
55,996 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

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