結果

問題 No.2285 Make A Unit Square
ユーザー 👑 rin204rin204
提出日時 2024-04-29 21:32:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 397 ms / 2,000 ms
コード長 638 bytes
コンパイル時間 203 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 78,208 KB
最終ジャッジ日時 2024-04-29 21:33:02
合計ジャッジ時間 2,249 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
59,136 KB
testcase_01 AC 52 ms
60,032 KB
testcase_02 AC 329 ms
77,312 KB
testcase_03 AC 321 ms
77,184 KB
testcase_04 AC 397 ms
78,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

memo = {}


def f(n):
    if n == 2 or n == 3:
        return 0
    if n in memo:
        return memo[n]

    se = set()
    for i in range(2, n):
        j = n - i
        if i > j:
            break
        se.add(f(i) ^ f(j))
    mex = 0
    while mex in se:
        mex += 1
    memo[n] = mex
    return mex


G = [0, 0]
for n in range(2, 102):
    G.append(f(n))


def g(n):
    minus = max(0, (n - 102) // 34 * 34)
    n -= minus
    while n >= len(G):
        n -= 34
    return G[n]


for _ in range(int(input())):
    a, b = map(int, input().split())
    if g(a) != g(b):
        print("First")
    else:
        print("Second")
0