結果
| 問題 |
No.726 Tree Game
|
| コンテスト | |
| ユーザー |
nadare
|
| 提出日時 | 2018-08-24 22:07:35 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 849 bytes |
| コンパイル時間 | 92 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 11,392 KB |
| 最終ジャッジ日時 | 2024-06-23 07:32:12 |
| 合計ジャッジ時間 | 1,896 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 21 WA * 4 |
ソースコード
# -*- 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")
nadare