結果

問題 No.726 Tree Game
ユーザー GrayCoderGrayCoder
提出日時 2018-08-24 22:34:40
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 765 bytes
コンパイル時間 627 ms
コンパイル使用メモリ 10,832 KB
実行使用メモリ 8,024 KB
最終ジャッジ日時 2023-09-05 12:34:48
合計ジャッジ時間 2,069 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,860 KB
testcase_01 AC 16 ms
7,808 KB
testcase_02 AC 15 ms
7,856 KB
testcase_03 WA -
testcase_04 AC 15 ms
7,912 KB
testcase_05 AC 15 ms
7,808 KB
testcase_06 AC 15 ms
7,904 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 15 ms
7,904 KB
testcase_11 AC 15 ms
7,864 KB
testcase_12 AC 16 ms
7,840 KB
testcase_13 WA -
testcase_14 AC 16 ms
7,900 KB
testcase_15 AC 15 ms
7,844 KB
testcase_16 AC 17 ms
7,772 KB
testcase_17 AC 18 ms
7,860 KB
testcase_18 WA -
testcase_19 AC 18 ms
7,904 KB
testcase_20 AC 19 ms
7,840 KB
testcase_21 AC 18 ms
7,816 KB
testcase_22 AC 20 ms
7,856 KB
testcase_23 AC 18 ms
7,844 KB
testcase_24 AC 17 ms
7,916 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

    cnt = 0
    while 1:
        if is_prime(X + 1):
            break
        else:
            X += 1
            cnt += 1
    while 1:
        if is_prime(Y + 1):
            break
        else:
            Y += 1
            cnt += 1

    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