結果

問題 No.726 Tree Game
ユーザー 👑 KazunKazun
提出日時 2021-02-25 03:35:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 876 bytes
コンパイル時間 191 ms
コンパイル使用メモリ 81,676 KB
実行使用メモリ 59,384 KB
最終ジャッジ日時 2023-10-25 08:31:53
合計ジャッジ時間 2,162 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
53,444 KB
testcase_01 AC 38 ms
53,444 KB
testcase_02 AC 39 ms
53,444 KB
testcase_03 AC 39 ms
53,444 KB
testcase_04 AC 38 ms
53,444 KB
testcase_05 AC 38 ms
53,444 KB
testcase_06 AC 38 ms
53,444 KB
testcase_07 AC 38 ms
53,448 KB
testcase_08 AC 38 ms
53,444 KB
testcase_09 WA -
testcase_10 AC 38 ms
53,444 KB
testcase_11 AC 38 ms
53,444 KB
testcase_12 AC 38 ms
53,444 KB
testcase_13 AC 38 ms
53,448 KB
testcase_14 AC 38 ms
53,444 KB
testcase_15 AC 39 ms
53,444 KB
testcase_16 AC 43 ms
59,384 KB
testcase_17 AC 42 ms
59,384 KB
testcase_18 AC 42 ms
59,384 KB
testcase_19 AC 43 ms
59,384 KB
testcase_20 AC 44 ms
59,384 KB
testcase_21 AC 43 ms
59,384 KB
testcase_22 AC 43 ms
59,384 KB
testcase_23 AC 43 ms
59,380 KB
testcase_24 AC 42 ms
59,384 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Is_Prime(N):
    N=abs(N)
    if N<=1:
        return False

    if N in {2,3,5}:
        return True

    r=N%6
    if not(r==1 or r==5):
        return False

    k=5
    Flag=1
    while k*k<=N:
        if N%k==0:
            return False

        k+=2 if Flag else 4
        Flag^=1
    return True

def Next_Prime(N,K=1):
    """
    Nを上回る自然数のうち,K番目に小さい素数

    N:自然数
    """
    if K>0:
        while K>0:
            N+=1
            if Is_Prime(N):
                K-=1
    else:
        while K<0:
            N-=1
            if Is_Prime(N):
                K+=1
    return N
#================================================
Y,X=map(int,input().split())

if Is_Prime(X) and Is_Prime(Y):
    print("Second")
    exit()

alpha=Next_Prime(Y)-1
beta =Next_Prime(X)-1
T=(alpha+beta)-(X+Y)

print("First" if T%2 else "Second")
0