結果

問題 No.726 Tree Game
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-23 15:25:22
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,015 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 87,212 KB
実行使用メモリ 257,824 KB
最終ジャッジ日時 2023-09-06 17:46:00
合計ジャッジ時間 9,570 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,652 KB
testcase_01 AC 71 ms
71,656 KB
testcase_02 AC 72 ms
71,848 KB
testcase_03 AC 74 ms
71,656 KB
testcase_04 AC 77 ms
71,504 KB
testcase_05 AC 72 ms
71,824 KB
testcase_06 AC 72 ms
71,512 KB
testcase_07 AC 71 ms
71,608 KB
testcase_08 AC 71 ms
71,768 KB
testcase_09 AC 73 ms
71,716 KB
testcase_10 AC 74 ms
71,656 KB
testcase_11 AC 74 ms
71,540 KB
testcase_12 WA -
testcase_13 AC 73 ms
71,656 KB
testcase_14 AC 74 ms
71,820 KB
testcase_15 AC 74 ms
71,736 KB
testcase_16 AC 800 ms
257,252 KB
testcase_17 AC 817 ms
257,312 KB
testcase_18 AC 435 ms
243,980 KB
testcase_19 AC 783 ms
257,160 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 833 ms
257,316 KB
testcase_23 AC 809 ms
257,384 KB
testcase_24 AC 811 ms
257,476 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# 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 main(x0,y0):
  if x0>y0:x0,y0=y0,x0
  x1=eratosthenes0(x0)
  y1=eratosthenes0(y0)
  if x0==1 and y0==1:
    return False
  elif x0==1 or y0==1:
    # x0が1
    y1=eratosthenes0(y0+1) # y0より真に大きい素数
    if (y1-y0)%2==0:
      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 main(x0+1,y0)
    else:
      return not main(x0,y0+1)
  else:
    if (x1-x0)+(y1-y0) % 2 == 0:
      return True
    else:
      return False
if __name__=='__main__':
  x,y=map(int,input().split())
  ret=main(x,y)
  if ret:
    print("First")
  else:
    print("Second")
0