結果
問題 | No.726 Tree Game |
ユーザー | 👑 H20 |
提出日時 | 2021-11-25 13:22:41 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 76 ms / 2,000 ms |
コード長 | 1,073 bytes |
コンパイル時間 | 570 ms |
コンパイル使用メモリ | 86,412 KB |
実行使用メモリ | 71,200 KB |
最終ジャッジ日時 | 2023-09-10 13:01:53 |
合計ジャッジ時間 | 4,229 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 74 ms
70,672 KB |
testcase_01 | AC | 75 ms
70,848 KB |
testcase_02 | AC | 76 ms
70,744 KB |
testcase_03 | AC | 75 ms
70,972 KB |
testcase_04 | AC | 76 ms
70,864 KB |
testcase_05 | AC | 72 ms
70,872 KB |
testcase_06 | AC | 72 ms
70,872 KB |
testcase_07 | AC | 73 ms
70,908 KB |
testcase_08 | AC | 73 ms
71,024 KB |
testcase_09 | AC | 73 ms
71,108 KB |
testcase_10 | AC | 73 ms
70,952 KB |
testcase_11 | AC | 71 ms
70,808 KB |
testcase_12 | AC | 72 ms
71,060 KB |
testcase_13 | AC | 72 ms
70,864 KB |
testcase_14 | AC | 72 ms
70,768 KB |
testcase_15 | AC | 72 ms
70,952 KB |
testcase_16 | AC | 72 ms
71,036 KB |
testcase_17 | AC | 71 ms
71,112 KB |
testcase_18 | AC | 72 ms
71,112 KB |
testcase_19 | AC | 72 ms
70,876 KB |
testcase_20 | AC | 72 ms
71,108 KB |
testcase_21 | AC | 74 ms
71,200 KB |
testcase_22 | AC | 72 ms
70,760 KB |
testcase_23 | AC | 72 ms
71,144 KB |
testcase_24 | AC | 72 ms
70,912 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()) if Y==2 or X==2: print('Second') exit() 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')