結果

問題 No.726 Tree Game
ユーザー lam6er
提出日時 2025-04-15 23:30:09
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 627 bytes
コンパイル時間 450 ms
コンパイル使用メモリ 82,004 KB
実行使用メモリ 53,520 KB
最終ジャッジ日時 2025-04-15 23:31:32
合計ジャッジ時間 2,120 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def is_prime(n):
    if n <= 1:
        return False
    if n <= 3:
        return True
    if n % 2 == 0 or n % 3 == 0:
        return False
    i = 5
    w = 2
    while i * i <= n:
        if n % i == 0:
            return False
        i += w
        w = 6 - w
    return True

def is_prime_cell(y, x):
    return is_prime(y) or is_prime(x)

Y, X = map(int, input().split())

# Check if current position is a dead end (both next moves are primes)
move_up_prime = is_prime_cell(Y+1, X)
move_right_prime = is_prime_cell(Y, X+1)

if move_up_prime and move_right_prime:
    print("Second")
else:
    print("First")
0