結果

問題 No.726 Tree Game
ユーザー mjkttenhoubotmjkttenhoubot
提出日時 2018-08-24 22:22:27
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 804 bytes
コンパイル時間 73 ms
コンパイル使用メモリ 10,968 KB
実行使用メモリ 14,880 KB
最終ジャッジ日時 2023-09-05 12:17:08
合計ジャッジ時間 4,878 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
14,880 KB
testcase_01 AC 17 ms
7,772 KB
testcase_02 AC 16 ms
7,844 KB
testcase_03 AC 17 ms
7,912 KB
testcase_04 AC 16 ms
7,940 KB
testcase_05 AC 16 ms
7,908 KB
testcase_06 AC 16 ms
7,804 KB
testcase_07 AC 16 ms
7,928 KB
testcase_08 AC 16 ms
7,864 KB
testcase_09 AC 16 ms
7,776 KB
testcase_10 AC 16 ms
7,848 KB
testcase_11 AC 16 ms
7,912 KB
testcase_12 AC 16 ms
7,948 KB
testcase_13 AC 16 ms
7,840 KB
testcase_14 AC 16 ms
7,972 KB
testcase_15 AC 16 ms
7,860 KB
testcase_16 AC 17 ms
7,812 KB
testcase_17 AC 129 ms
7,804 KB
testcase_18 AC 16 ms
7,792 KB
testcase_19 AC 217 ms
7,892 KB
testcase_20 AC 130 ms
7,848 KB
testcase_21 TLE -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

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