結果

問題 No.726 Tree Game
ユーザー mjkttenhoubot
提出日時 2018-08-24 22:22:27
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
TLE  
実行時間 -
コード長 804 bytes
コンパイル時間 91 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 16,256 KB
最終ジャッジ日時 2024-06-23 07:55:01
合計ジャッジ時間 4,861 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21 TLE * 1 -- * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

def isPrime(num):
    if num==1:
        return False
    if num==2:
        return True
    if num%2==0:
        return False
    for i in range(3,int(num**.5)+1,2):
        if num%i==0:
            return False
    return True

def simulate(x,y,teban):

    go_x = isPrime(x+1) or isPrime(y)
    go_y = isPrime(x) or isPrime(y+1)

    if go_x+go_y == 2:
        return teban%2==1
    elif go_x:
        return simulate(x,y+1,teban+1)
    elif go_y:
        return simulate(x+1,y,teban+1)
    else:
        if simulate(x+1,y,teban+1)==(teban%2==0):
            return teban%2==0
        elif simulate(x,y+1,teban+1)==(teban%2==0):
            return teban%2==0
        else:
            return teban%2==1


x,y = map(int,input().split())
if simulate(x,y,0):
    print('First')
else:
    print('Second')
0