結果

問題 No.726 Tree Game
ユーザー brthyyjpbrthyyjp
提出日時 2022-02-18 14:32:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 81 ms / 2,000 ms
コード長 689 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 86,956 KB
実行使用メモリ 75,272 KB
最終ジャッジ日時 2023-09-11 18:10:35
合計ジャッジ時間 3,398 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,036 KB
testcase_01 AC 75 ms
71,276 KB
testcase_02 AC 75 ms
71,248 KB
testcase_03 AC 75 ms
71,424 KB
testcase_04 AC 76 ms
71,276 KB
testcase_05 AC 76 ms
71,036 KB
testcase_06 AC 77 ms
71,036 KB
testcase_07 AC 76 ms
71,296 KB
testcase_08 AC 75 ms
71,420 KB
testcase_09 AC 76 ms
71,248 KB
testcase_10 AC 77 ms
71,404 KB
testcase_11 AC 76 ms
71,256 KB
testcase_12 AC 76 ms
71,200 KB
testcase_13 AC 76 ms
71,052 KB
testcase_14 AC 75 ms
71,212 KB
testcase_15 AC 77 ms
71,456 KB
testcase_16 AC 81 ms
75,252 KB
testcase_17 AC 80 ms
75,176 KB
testcase_18 AC 79 ms
75,180 KB
testcase_19 AC 79 ms
75,220 KB
testcase_20 AC 80 ms
75,048 KB
testcase_21 AC 77 ms
75,272 KB
testcase_22 AC 79 ms
75,016 KB
testcase_23 AC 79 ms
74,896 KB
testcase_24 AC 79 ms
75,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import math

def is_prime(n):
    if n == 1:
        return False

    for i in range(2, int(math.sqrt(n))+1):
        if n%i == 0:
            return False

    return True

y, x = map(int, input().split())
d = 10**5
for yp in range(y+1, y+d):
    if is_prime(yp):
        break
for xp in range(x+1, x+d):
    if is_prime(xp):
        break
        
dx = xp-x-1
dy = yp-y-1

if dy == 0:
    if is_prime(y):
        print('Second')
        exit()
if dx == 0:
    if is_prime(x):
        print('Second')
        exit()

if dy%2 == 0:
    if dx%2 == 1:
        print('First')
    else:
        print('Second')
else:
    if dx%2 == 1:
        print('Second')
    else:
        print('First')
0