結果

問題 No.726 Tree Game
ユーザー YamaKasaYamaKasa
提出日時 2018-08-24 21:49:37
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 743 bytes
コンパイル時間 3,330 ms
コンパイル使用メモリ 72,140 KB
実行使用メモリ 57,940 KB
最終ジャッジ日時 2023-09-05 11:26:10
合計ジャッジ時間 7,504 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
57,940 KB
testcase_01 AC 126 ms
55,600 KB
testcase_02 AC 129 ms
56,108 KB
testcase_03 AC 124 ms
56,048 KB
testcase_04 AC 124 ms
55,964 KB
testcase_05 AC 125 ms
55,796 KB
testcase_06 AC 123 ms
55,968 KB
testcase_07 WA -
testcase_08 AC 125 ms
55,864 KB
testcase_09 WA -
testcase_10 AC 124 ms
55,980 KB
testcase_11 AC 125 ms
55,580 KB
testcase_12 AC 121 ms
56,132 KB
testcase_13 AC 126 ms
55,968 KB
testcase_14 AC 126 ms
55,736 KB
testcase_15 AC 124 ms
55,612 KB
testcase_16 AC 126 ms
55,548 KB
testcase_17 AC 124 ms
55,568 KB
testcase_18 AC 125 ms
56,248 KB
testcase_19 AC 124 ms
55,744 KB
testcase_20 AC 123 ms
55,748 KB
testcase_21 AC 125 ms
56,136 KB
testcase_22 AC 126 ms
55,792 KB
testcase_23 AC 126 ms
55,720 KB
testcase_24 AC 127 ms
56,068 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 <= (long)Math.sqrt(n); i += 2){
            if(n % i == 0) {
                return false;
            }
        }
        return true;
    }
}
0