結果
| 問題 |
No.726 Tree Game
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-06-23 15:45:15 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 791 ms / 2,000 ms |
| コード長 | 1,052 bytes |
| コンパイル時間 | 147 ms |
| コンパイル使用メモリ | 82,304 KB |
| 実行使用メモリ | 246,292 KB |
| 最終ジャッジ日時 | 2024-06-24 12:28:33 |
| 合計ジャッジ時間 | 8,221 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 |
ソースコード
# n以上の素数で最小のものを返す
def eratosthenes0(n):
nu=n+min(n,10**6)
kouho=set(range(n,nu))
for x in range(2,int(nu**.5)+1):
xx=x*(n//x)
while xx<nu:
kouho.discard(xx)
xx+=x
return min(kouho)
def main1(x0,y0):
if x0>y0:x0,y0=y0,x0
x1=eratosthenes0(x0)
y1=eratosthenes0(y0)
#print(x0,y0,x1,y1)
if x0==1 and y0==1:
return False
elif x0==1 or y0==1:
# x0が1
y1=eratosthenes0(y0+1) # y0より真に大きい素数
if (y1-y0-1)%2==1:
return True
else:
return False
elif x0==2 or y0==2:
# (2,8)->(2,9) ng
# (2,8)->(3,8) ng
return False
elif x0==x1 and y0==y1:
return False
elif x0==x1 or y0==y1:
# 素数の座標を動かす
if x0==x1:
return not main1(x0+1,y0)
else:
return not main1(x0,y0+1)
else:
if ((x1-x0-1)+(y1-y0-1)) % 2 == 1:
return True
else:
return False
if __name__=='__main__':
x,y=map(int,input().split())
ret1=main1(x,y)
if ret1:
print("First")
else:
print("Second")