結果

問題 No.726 Tree Game
ユーザー simamumusimamumu
提出日時 2018-08-24 23:36:24
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 115 ms / 2,000 ms
コード長 1,057 bytes
コンパイル時間 86 ms
コンパイル使用メモリ 11,020 KB
実行使用メモリ 10,548 KB
最終ジャッジ日時 2023-09-05 14:54:45
合計ジャッジ時間 2,533 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
10,408 KB
testcase_01 AC 32 ms
10,488 KB
testcase_02 AC 33 ms
10,548 KB
testcase_03 AC 33 ms
10,468 KB
testcase_04 AC 32 ms
10,424 KB
testcase_05 AC 33 ms
10,364 KB
testcase_06 AC 32 ms
10,412 KB
testcase_07 AC 33 ms
10,340 KB
testcase_08 AC 33 ms
10,320 KB
testcase_09 AC 33 ms
10,528 KB
testcase_10 AC 33 ms
10,492 KB
testcase_11 AC 34 ms
10,532 KB
testcase_12 AC 34 ms
10,356 KB
testcase_13 AC 33 ms
10,400 KB
testcase_14 AC 33 ms
10,484 KB
testcase_15 AC 34 ms
10,416 KB
testcase_16 AC 34 ms
10,472 KB
testcase_17 AC 48 ms
10,320 KB
testcase_18 AC 33 ms
10,372 KB
testcase_19 AC 51 ms
10,360 KB
testcase_20 AC 54 ms
10,360 KB
testcase_21 AC 52 ms
10,420 KB
testcase_22 AC 115 ms
10,364 KB
testcase_23 AC 87 ms
10,424 KB
testcase_24 AC 53 ms
10,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

X,Y = inpl()
MAX = 10**1333
flag = True #True -> Second

def is_prime(x):
    if x < 2: return False # 2未満に素数はない
    if x == 2 or x == 3 or x == 5: return True # 2,3,5は素数
    if x % 2 == 0 or x % 3 == 0 or x % 5 == 0: return False # 2,3,5の倍数は合成数

    # ためし割り: 疑似素数(2でも3でも5でも割り切れない数字)で次々に割っていく
    prime = 7
    step = 4
    while prime <= math.sqrt(x):
        if x % prime == 0: return False

        prime += step
        step = 6 - step

    return True

while True:
	if (not is_prime(X+1)) and (not is_prime(Y)):
		X += 1
		flag = not flag
	elif (not is_prime(X)) and (not is_prime(Y+1)):
		Y += 1
		flag = not flag
	else:
		break

if flag:
	print('Second')
else:
	print('First')
0