結果

問題 No.726 Tree Game
ユーザー 👑 H20H20
提出日時 2021-11-25 13:15:20
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 997 bytes
コンパイル時間 685 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 71,604 KB
最終ジャッジ日時 2023-09-10 12:42:52
合計ジャッジ時間 3,771 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
70,904 KB
testcase_01 AC 72 ms
70,996 KB
testcase_02 AC 74 ms
71,064 KB
testcase_03 AC 71 ms
71,000 KB
testcase_04 AC 73 ms
70,652 KB
testcase_05 AC 73 ms
70,984 KB
testcase_06 AC 72 ms
70,888 KB
testcase_07 WA -
testcase_08 AC 73 ms
71,016 KB
testcase_09 WA -
testcase_10 AC 74 ms
70,900 KB
testcase_11 AC 74 ms
71,084 KB
testcase_12 AC 74 ms
70,728 KB
testcase_13 AC 73 ms
70,648 KB
testcase_14 AC 73 ms
71,104 KB
testcase_15 AC 73 ms
70,856 KB
testcase_16 AC 73 ms
70,736 KB
testcase_17 AC 75 ms
70,888 KB
testcase_18 AC 73 ms
70,932 KB
testcase_19 AC 73 ms
71,020 KB
testcase_20 AC 75 ms
70,756 KB
testcase_21 AC 74 ms
71,084 KB
testcase_22 AC 75 ms
70,856 KB
testcase_23 AC 73 ms
71,024 KB
testcase_24 AC 75 ms
70,776 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

# python
# 補助関数
def suspect(a, t, n):
    x = pow(a, t, n)
    n1 = n - 1
    while t != n1 and x != 1 and x != n1:
        x = pow(x, 2, n)
        t <<= 1
    return t & 1 or x == n1

# メイン
# 2^64までの決定的アルゴリズムとして実装しているので、ランダム要素は無い
# ランダムとして用いる場合は、check_listにランダム抽出された数を採用し、20~50個程度試す
def miller_rabin(n):
    if n == 2:
        return True
    if n < 2 or n % 2 == 0:
        return False
    d = (n - 1) >> 1
    while d & 1 == 0:
        d >>= 1
    check_list = (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41)
    for i in check_list:
        if i >= n:
            break
        if not suspect(i, d, n):
            return False
    return True

Y,X = map(int,input().split())
y = Y
x = X
while not miller_rabin(y+1):
    y+=1
while not miller_rabin(x+1):
    x+=1
temp = y-Y+x-X
if temp%2==0:
    print('Second')
else:
    print('First')
0