結果

問題 No.726 Tree Game
ユーザー GrayCoder
提出日時 2018-08-24 22:08:25
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 874 bytes
コンパイル時間 85 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,752 KB
最終ジャッジ日時 2024-06-23 07:34:26
合計ジャッジ時間 1,529 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 16 WA * 9
権限があれば一括ダウンロードができます

ソースコード

diff #

from sys import stdin, stdout

input = lambda: stdin.readline()
write = stdout.write

def main():
    Y, X = map(int, input().split())

    if is_prime(X) or is_prime(Y):
        print('First')
        return

    x, y = X + 1, Y + 1
    xflag, yflag = 0, 0
    cnt = 0
    while 1:
        if not xflag and is_prime(x):
            xflag = 1
        else:
            x += 1
            cnt += 1
        if not yflag and is_prime(y):
            yflag = 1
        else:
            y += 1
            cnt += 1
        if xflag and yflag:
            break

    if cnt % 2:
        print('First')
    else:
        print('Second')

def is_prime(n):
    if n == 2:
        return True
    if n < 2 or not n & 1:
        return False

    for i in range(3, n, 2):
        if not n % i:
            return False
        if i * i >= n:
            break
    return True

main()
0