結果

問題 No.726 Tree Game
ユーザー YamaKasaYamaKasa
提出日時 2018-08-24 21:44:24
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 742 bytes
コンパイル時間 2,440 ms
コンパイル使用メモリ 71,908 KB
実行使用メモリ 56,328 KB
最終ジャッジ日時 2023-09-05 11:20:14
合計ジャッジ時間 6,757 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 125 ms
55,596 KB
testcase_01 AC 125 ms
54,076 KB
testcase_02 AC 124 ms
55,928 KB
testcase_03 AC 125 ms
56,100 KB
testcase_04 AC 124 ms
56,328 KB
testcase_05 AC 124 ms
55,944 KB
testcase_06 AC 125 ms
55,940 KB
testcase_07 WA -
testcase_08 AC 122 ms
55,932 KB
testcase_09 WA -
testcase_10 AC 126 ms
54,108 KB
testcase_11 AC 124 ms
56,180 KB
testcase_12 AC 123 ms
56,004 KB
testcase_13 AC 123 ms
56,076 KB
testcase_14 AC 123 ms
56,176 KB
testcase_15 AC 123 ms
55,608 KB
testcase_16 AC 123 ms
56,016 KB
testcase_17 AC 124 ms
56,152 KB
testcase_18 AC 125 ms
55,868 KB
testcase_19 AC 127 ms
55,996 KB
testcase_20 AC 125 ms
55,836 KB
testcase_21 AC 127 ms
56,108 KB
testcase_22 AC 127 ms
56,104 KB
testcase_23 AC 126 ms
55,736 KB
testcase_24 AC 124 ms
55,932 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(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