結果

問題 No.726 Tree Game
ユーザー nadarenadare
提出日時 2018-08-24 22:14:11
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 839 bytes
コンパイル時間 140 ms
コンパイル使用メモリ 10,932 KB
実行使用メモリ 8,856 KB
最終ジャッジ日時 2023-09-05 12:06:33
合計ジャッジ時間 1,915 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 25 ms
8,724 KB
testcase_01 AC 24 ms
8,768 KB
testcase_02 AC 24 ms
8,852 KB
testcase_03 AC 24 ms
8,720 KB
testcase_04 AC 24 ms
8,712 KB
testcase_05 AC 24 ms
8,856 KB
testcase_06 AC 24 ms
8,784 KB
testcase_07 WA -
testcase_08 AC 24 ms
8,728 KB
testcase_09 WA -
testcase_10 AC 24 ms
8,792 KB
testcase_11 AC 24 ms
8,648 KB
testcase_12 AC 25 ms
8,792 KB
testcase_13 AC 23 ms
8,716 KB
testcase_14 AC 23 ms
8,720 KB
testcase_15 AC 24 ms
8,740 KB
testcase_16 AC 23 ms
8,708 KB
testcase_17 AC 24 ms
8,728 KB
testcase_18 AC 24 ms
8,764 KB
testcase_19 AC 24 ms
8,760 KB
testcase_20 AC 24 ms
8,724 KB
testcase_21 AC 25 ms
8,720 KB
testcase_22 AC 25 ms
8,840 KB
testcase_23 AC 24 ms
8,748 KB
testcase_24 AC 24 ms
8,748 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
i = 0
while (not isprime(X, P)) or (i==0):
    i += 1
    X += 1
    secwin = not secwin

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

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