結果

問題 No.726 Tree Game
ユーザー 👑 KazunKazun
提出日時 2021-02-25 03:48:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 60 ms / 2,000 ms
コード長 896 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 81,760 KB
実行使用メモリ 59,376 KB
最終ジャッジ日時 2023-10-25 08:44:28
合計ジャッジ時間 2,349 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
53,436 KB
testcase_01 AC 41 ms
53,436 KB
testcase_02 AC 39 ms
53,436 KB
testcase_03 AC 39 ms
53,440 KB
testcase_04 AC 38 ms
53,436 KB
testcase_05 AC 38 ms
53,436 KB
testcase_06 AC 39 ms
53,436 KB
testcase_07 AC 39 ms
53,440 KB
testcase_08 AC 38 ms
53,440 KB
testcase_09 AC 39 ms
53,440 KB
testcase_10 AC 39 ms
53,436 KB
testcase_11 AC 38 ms
53,436 KB
testcase_12 AC 39 ms
53,436 KB
testcase_13 AC 39 ms
53,440 KB
testcase_14 AC 39 ms
53,436 KB
testcase_15 AC 39 ms
53,436 KB
testcase_16 AC 60 ms
59,376 KB
testcase_17 AC 44 ms
59,376 KB
testcase_18 AC 39 ms
53,452 KB
testcase_19 AC 44 ms
59,376 KB
testcase_20 AC 44 ms
59,376 KB
testcase_21 AC 43 ms
59,376 KB
testcase_22 AC 44 ms
59,376 KB
testcase_23 AC 44 ms
59,372 KB
testcase_24 AC 44 ms
59,376 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)) or (X==2 or Y==2):
    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