結果

問題 No.726 Tree Game
ユーザー nadarenadare
提出日時 2018-08-24 22:07:35
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 849 bytes
コンパイル時間 212 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 8,896 KB
最終ジャッジ日時 2023-09-05 11:55:07
合計ジャッジ時間 1,767 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
8,720 KB
testcase_01 WA -
testcase_02 AC 23 ms
8,692 KB
testcase_03 AC 24 ms
8,644 KB
testcase_04 WA -
testcase_05 AC 24 ms
8,720 KB
testcase_06 WA -
testcase_07 AC 23 ms
8,732 KB
testcase_08 AC 24 ms
8,672 KB
testcase_09 AC 23 ms
8,740 KB
testcase_10 AC 24 ms
8,856 KB
testcase_11 AC 24 ms
8,752 KB
testcase_12 AC 24 ms
8,620 KB
testcase_13 AC 24 ms
8,744 KB
testcase_14 WA -
testcase_15 AC 23 ms
8,756 KB
testcase_16 AC 25 ms
8,700 KB
testcase_17 AC 25 ms
8,744 KB
testcase_18 AC 24 ms
8,760 KB
testcase_19 AC 24 ms
8,644 KB
testcase_20 AC 24 ms
8,896 KB
testcase_21 AC 24 ms
8,716 KB
testcase_22 AC 25 ms
8,740 KB
testcase_23 AC 25 ms
8,716 KB
testcase_24 AC 24 ms
8,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-
from bisect import bisect, bisect_left
from math import sqrt

def primes(N):
    sieve = [True]*(N+1)
    sieve[:2] = [False, False]
    P = []
    
    for i in range(2, N):
        if sieve[i]:
            P.append(i)
            for j in range(2*i, N, i):
                sieve[j] = False
    return P

def isprime(X, P):
    if X <= P[-1]:
        return X == P[bisect_left(P, X)]
    for p in P[:bisect(P, sqrt(X)+1)]:
        if X%p == 0:
            return False
    else:
        return True

P = primes(int(sqrt(2*10**9)))
X, Y = map(int, input().split())

secwin = True

if isprime(X, P) or isprime(Y, P):
    print("Second")
    exit()

while not isprime(X, P):
    X += 1
    secwin = not secwin

while not isprime(Y, P):
    Y += 1
    secwin = not secwin

if secwin:
    print("Second")
else:
    print("First")
0