結果

問題 No.726 Tree Game
ユーザー nadarenadare
提出日時 2018-08-24 21:56:10
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
実行時間 -
コード長 782 bytes
コンパイル時間 79 ms
コンパイル使用メモリ 11,004 KB
実行使用メモリ 8,920 KB
最終ジャッジ日時 2023-09-05 11:36:49
合計ジャッジ時間 1,875 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 24 ms
8,720 KB
testcase_01 AC 24 ms
8,864 KB
testcase_02 AC 25 ms
8,712 KB
testcase_03 WA -
testcase_04 AC 24 ms
8,800 KB
testcase_05 AC 24 ms
8,872 KB
testcase_06 AC 24 ms
8,892 KB
testcase_07 AC 24 ms
8,868 KB
testcase_08 WA -
testcase_09 AC 24 ms
8,732 KB
testcase_10 AC 24 ms
8,720 KB
testcase_11 AC 24 ms
8,820 KB
testcase_12 AC 24 ms
8,804 KB
testcase_13 AC 24 ms
8,664 KB
testcase_14 AC 24 ms
8,888 KB
testcase_15 AC 24 ms
8,896 KB
testcase_16 AC 24 ms
8,880 KB
testcase_17 AC 24 ms
8,920 KB
testcase_18 WA -
testcase_19 AC 24 ms
8,716 KB
testcase_20 AC 25 ms
8,724 KB
testcase_21 AC 25 ms
8,736 KB
testcase_22 AC 25 ms
8,664 KB
testcase_23 AC 25 ms
8,796 KB
testcase_24 AC 25 ms
8,712 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

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