結果

問題 No.726 Tree Game
ユーザー 👑 rin204rin204
提出日時 2022-10-30 17:03:22
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 75 ms / 2,000 ms
コード長 940 bytes
コンパイル時間 387 ms
コンパイル使用メモリ 86,984 KB
実行使用メモリ 71,272 KB
最終ジャッジ日時 2023-09-21 14:39:26
合計ジャッジ時間 3,239 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,148 KB
testcase_01 AC 71 ms
71,000 KB
testcase_02 AC 73 ms
70,904 KB
testcase_03 AC 70 ms
71,060 KB
testcase_04 AC 70 ms
71,044 KB
testcase_05 AC 71 ms
71,072 KB
testcase_06 AC 70 ms
71,092 KB
testcase_07 AC 72 ms
71,076 KB
testcase_08 AC 73 ms
71,148 KB
testcase_09 AC 72 ms
71,172 KB
testcase_10 AC 75 ms
70,912 KB
testcase_11 AC 70 ms
71,084 KB
testcase_12 AC 71 ms
70,992 KB
testcase_13 AC 70 ms
71,236 KB
testcase_14 AC 73 ms
70,988 KB
testcase_15 AC 70 ms
71,200 KB
testcase_16 AC 71 ms
71,148 KB
testcase_17 AC 71 ms
70,928 KB
testcase_18 AC 72 ms
71,208 KB
testcase_19 AC 70 ms
70,992 KB
testcase_20 AC 73 ms
71,272 KB
testcase_21 AC 72 ms
71,112 KB
testcase_22 AC 70 ms
71,220 KB
testcase_23 AC 71 ms
71,052 KB
testcase_24 AC 71 ms
71,056 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def isprime(n):
    if n <= 1:
        return False
    elif n == 2:
        return True
    elif n % 2 == 0:
        return False
    
    A = [2, 325, 9375, 28178, 450775, 9780504, 1795265022]
    s = 0
    d = n - 1
    while d % 2 == 0:
        s += 1
        d >>= 1
    
    for a in A:
        if a % n == 0:
            return True
        x = pow(a, d, n)
        if x != 1:
            for t in range(s):
                if x == n - 1:
                    break
                x = x * x % n
            else:
                return False
    return True
        


y, x = map(int, input().split())
if x > y:
    x, y = y, x

if isprime(y) and isprime(x):
    print("Second")
elif x == 2 or y == 2:
    print("Second")
elif x == 1 and y == 1:
    print("Second")
elif (y + x) & 1:
    if x == 1:
        print("Second")
    else:
        print("First")
else:
    if x == 1:
        print("First")
    else:
        print("Second")
0