結果
問題 | No.726 Tree Game |
ユーザー | 👑 H20 |
提出日時 | 2021-11-25 13:05:36 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,007 bytes |
コンパイル時間 | 789 ms |
コンパイル使用メモリ | 86,868 KB |
実行使用メモリ | 71,404 KB |
最終ジャッジ日時 | 2023-09-10 12:32:40 |
合計ジャッジ時間 | 4,426 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 71 ms
71,264 KB |
testcase_01 | AC | 72 ms
71,164 KB |
testcase_02 | AC | 72 ms
71,100 KB |
testcase_03 | AC | 72 ms
71,388 KB |
testcase_04 | WA | - |
testcase_05 | AC | 71 ms
71,160 KB |
testcase_06 | WA | - |
testcase_07 | AC | 71 ms
71,252 KB |
testcase_08 | AC | 71 ms
71,120 KB |
testcase_09 | AC | 71 ms
71,208 KB |
testcase_10 | AC | 72 ms
71,304 KB |
testcase_11 | AC | 71 ms
71,404 KB |
testcase_12 | AC | 71 ms
71,328 KB |
testcase_13 | AC | 72 ms
71,168 KB |
testcase_14 | AC | 72 ms
70,944 KB |
testcase_15 | AC | 73 ms
70,888 KB |
testcase_16 | WA | - |
testcase_17 | AC | 74 ms
70,900 KB |
testcase_18 | WA | - |
testcase_19 | AC | 72 ms
71,336 KB |
testcase_20 | AC | 73 ms
71,124 KB |
testcase_21 | AC | 72 ms
71,392 KB |
testcase_22 | AC | 72 ms
71,252 KB |
testcase_23 | AC | 73 ms
71,252 KB |
testcase_24 | AC | 71 ms
71,324 KB |
ソースコード
# 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 miller_rabin(y+1): y+=1 while miller_rabin(x+1): x+=1 if (y-Y+x-Y)%2==0: print('Second') else: print('First')