結果

問題 No.726 Tree Game
ユーザー GrayCoderGrayCoder
提出日時 2018-08-24 22:08:25
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 874 bytes
コンパイル時間 554 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 7,992 KB
最終ジャッジ日時 2023-09-05 11:57:24
合計ジャッジ時間 1,659 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,888 KB
testcase_01 AC 16 ms
7,800 KB
testcase_02 AC 16 ms
7,820 KB
testcase_03 WA -
testcase_04 AC 16 ms
7,808 KB
testcase_05 AC 16 ms
7,856 KB
testcase_06 AC 15 ms
7,848 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 16 ms
7,824 KB
testcase_11 AC 16 ms
7,904 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 16 ms
7,856 KB
testcase_15 AC 15 ms
7,844 KB
testcase_16 AC 17 ms
7,856 KB
testcase_17 AC 19 ms
7,768 KB
testcase_18 WA -
testcase_19 AC 19 ms
7,884 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 21 ms
7,772 KB
testcase_23 AC 18 ms
7,844 KB
testcase_24 AC 17 ms
7,876 KB
権限があれば一括ダウンロードができます

ソースコード

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