結果

問題 No.726 Tree Game
ユーザー tktk_snsntktk_snsn
提出日時 2021-01-01 15:46:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 661 bytes
コンパイル時間 152 ms
コンパイル使用メモリ 82,520 KB
実行使用メモリ 61,816 KB
最終ジャッジ日時 2024-04-19 12:18:19
合計ジャッジ時間 2,190 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
55,244 KB
testcase_01 AC 44 ms
55,448 KB
testcase_02 AC 46 ms
55,840 KB
testcase_03 AC 44 ms
55,172 KB
testcase_04 AC 46 ms
55,836 KB
testcase_05 AC 45 ms
55,988 KB
testcase_06 AC 47 ms
56,680 KB
testcase_07 AC 46 ms
56,520 KB
testcase_08 AC 46 ms
55,100 KB
testcase_09 WA -
testcase_10 AC 45 ms
55,920 KB
testcase_11 AC 45 ms
55,952 KB
testcase_12 AC 45 ms
55,308 KB
testcase_13 AC 45 ms
56,592 KB
testcase_14 AC 45 ms
55,048 KB
testcase_15 AC 46 ms
56,380 KB
testcase_16 AC 48 ms
60,836 KB
testcase_17 AC 48 ms
60,824 KB
testcase_18 AC 49 ms
59,900 KB
testcase_19 AC 48 ms
61,560 KB
testcase_20 AC 48 ms
61,816 KB
testcase_21 AC 52 ms
61,424 KB
testcase_22 AC 50 ms
60,304 KB
testcase_23 AC 49 ms
60,900 KB
testcase_24 AC 49 ms
60,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache


@lru_cache(maxsize=None)
def isPrime(n):
    if n == 0 or n == 1:
        return False
    if n == 2:
        return True
    if n % 2 == 0:
        return False
    for i in range(3, int(n ** 0.5) + 1, 2):
        if n % i == 0:
            return False
    return True


def find_prime(x):
    x += 1
    for _ in range(5 * 10 ** 6):
        if isPrime(x):
            return x
        x += 1
    return -1


X, Y = map(int, input().split())
if isPrime(X) and isPrime(Y):
    print("Second")
    exit()

dx = find_prime(X) - X - 1
dy = find_prime(Y) - Y - 1
if (dx + dy) % 2 == 0:
    print("Second")
else:
    print("First")
0