結果

問題 No.726 Tree Game
ユーザー 👑 H20H20
提出日時 2021-11-25 13:09:10
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,025 bytes
コンパイル時間 855 ms
コンパイル使用メモリ 86,920 KB
実行使用メモリ 71,584 KB
最終ジャッジ日時 2023-09-10 12:37:21
合計ジャッジ時間 4,179 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
70,840 KB
testcase_01 AC 74 ms
70,864 KB
testcase_02 AC 74 ms
70,792 KB
testcase_03 AC 75 ms
70,872 KB
testcase_04 AC 77 ms
70,644 KB
testcase_05 AC 74 ms
70,872 KB
testcase_06 AC 76 ms
70,772 KB
testcase_07 WA -
testcase_08 AC 74 ms
70,996 KB
testcase_09 WA -
testcase_10 AC 76 ms
70,920 KB
testcase_11 AC 74 ms
70,648 KB
testcase_12 AC 76 ms
70,976 KB
testcase_13 AC 74 ms
70,872 KB
testcase_14 AC 73 ms
70,936 KB
testcase_15 AC 75 ms
70,864 KB
testcase_16 AC 75 ms
70,916 KB
testcase_17 AC 74 ms
70,784 KB
testcase_18 AC 75 ms
70,992 KB
testcase_19 AC 74 ms
71,184 KB
testcase_20 AC 73 ms
70,896 KB
testcase_21 AC 78 ms
71,032 KB
testcase_22 AC 74 ms
70,772 KB
testcase_23 AC 74 ms
71,128 KB
testcase_24 AC 74 ms
71,016 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, 7, 61) if n < 2 ** 32 else (2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37)
    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