結果

問題 No.726 Tree Game
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-23 15:45:15
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 670 ms / 2,000 ms
コード長 1,052 bytes
コンパイル時間 252 ms
コンパイル使用メモリ 86,972 KB
実行使用メモリ 257,224 KB
最終ジャッジ日時 2023-09-06 18:04:18
合計ジャッジ時間 8,523 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 66 ms
71,664 KB
testcase_01 AC 63 ms
71,812 KB
testcase_02 AC 61 ms
71,484 KB
testcase_03 AC 70 ms
71,640 KB
testcase_04 AC 61 ms
71,496 KB
testcase_05 AC 58 ms
71,676 KB
testcase_06 AC 58 ms
71,664 KB
testcase_07 AC 59 ms
71,548 KB
testcase_08 AC 61 ms
71,824 KB
testcase_09 AC 62 ms
71,544 KB
testcase_10 AC 59 ms
71,660 KB
testcase_11 AC 59 ms
71,824 KB
testcase_12 AC 60 ms
71,664 KB
testcase_13 AC 60 ms
71,540 KB
testcase_14 AC 63 ms
71,628 KB
testcase_15 AC 59 ms
71,740 KB
testcase_16 AC 670 ms
256,304 KB
testcase_17 AC 650 ms
256,876 KB
testcase_18 AC 366 ms
243,752 KB
testcase_19 AC 653 ms
256,720 KB
testcase_20 AC 663 ms
257,224 KB
testcase_21 AC 640 ms
257,036 KB
testcase_22 AC 652 ms
256,992 KB
testcase_23 AC 651 ms
256,976 KB
testcase_24 AC 634 ms
256,920 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 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")
0