結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 82 ms
8,644 KB
testcase_01 AC 80 ms
8,804 KB
testcase_02 AC 81 ms
8,664 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 81 ms
8,888 KB
testcase_09 WA -
testcase_10 AC 81 ms
8,776 KB
testcase_11 AC 81 ms
8,808 KB
testcase_12 AC 82 ms
8,728 KB
testcase_13 AC 79 ms
8,788 KB
testcase_14 AC 81 ms
8,740 KB
testcase_15 AC 81 ms
8,852 KB
testcase_16 WA -
testcase_17 AC 24 ms
8,768 KB
testcase_18 AC 52 ms
8,784 KB
testcase_19 AC 24 ms
8,808 KB
testcase_20 AC 24 ms
8,716 KB
testcase_21 AC 24 ms
8,812 KB
testcase_22 AC 25 ms
8,732 KB
testcase_23 AC 24 ms
8,720 KB
testcase_24 AC 25 ms
8,644 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 == bisect_left(P, X)
    for p in P[:bisect_left(P, sqrt(X))]:
        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