結果
問題 | No.726 Tree Game |
ユーザー | tenten |
提出日時 | 2020-09-02 12:59:08 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 888 bytes |
コンパイル時間 | 1,885 ms |
コンパイル使用メモリ | 77,716 KB |
実行使用メモリ | 54,232 KB |
最終ジャッジ日時 | 2024-05-01 10:30:08 |
合計ジャッジ時間 | 5,652 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 111 ms
54,036 KB |
testcase_01 | AC | 113 ms
54,004 KB |
testcase_02 | AC | 100 ms
52,840 KB |
testcase_03 | WA | - |
testcase_04 | AC | 113 ms
53,884 KB |
testcase_05 | AC | 114 ms
53,836 KB |
testcase_06 | AC | 103 ms
52,860 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 116 ms
54,144 KB |
testcase_11 | AC | 118 ms
54,232 KB |
testcase_12 | AC | 104 ms
53,012 KB |
testcase_13 | WA | - |
testcase_14 | AC | 116 ms
53,816 KB |
testcase_15 | AC | 112 ms
54,116 KB |
testcase_16 | AC | 111 ms
53,964 KB |
testcase_17 | AC | 111 ms
53,588 KB |
testcase_18 | WA | - |
testcase_19 | AC | 104 ms
52,576 KB |
testcase_20 | AC | 125 ms
54,064 KB |
testcase_21 | AC | 120 ms
53,824 KB |
testcase_22 | AC | 115 ms
54,012 KB |
testcase_23 | AC | 118 ms
53,780 KB |
testcase_24 | AC | 103 ms
52,592 KB |
ソースコード
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) { if (x == 1) { return false; } for (int i = 2; i <= Math.sqrt(x); i++) { if (x % i == 0) { return false; } } return true; } }