結果

問題 No.2551 2, 3, 5, 7 Game
コンテスト
ユーザー LyricalMaestro
提出日時 2026-07-17 23:53:53
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
TLE  
実行時間 -
コード長 1,321 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 415 ms
コンパイル使用メモリ 96,232 KB
実行使用メモリ 371,896 KB
最終ジャッジ日時 2026-07-17 23:54:00
合計ジャッジ時間 5,856 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 5 TLE * 1 -- * 4
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

## https://yukicoder.me/problems/no/2551

def solve(N):


    def dfs(x, memo):
        if x in memo:
            return memo[x]

        can_win = False
        for a in [2, 3, 5, 7]:
            if x * a >= N:
                break
            else:
                c = dfs(x * a, memo)
                if c == 0:
                    can_win = True
        if can_win:
            memo[x] = 1
            return 1
        else:
            memo[x] = 0
            return 0

    c = dfs(1, {})
    if c == 1:
        return "sepa"
    else:
        return "ryota"



def main():
    T = int(input())
    n_list = []
    for _ in range(T):
        N = int(input())
        n_list.append(N)


    def dfs(x, memo):
        if x in memo:
            return memo[x]

        can_win = False
        for a in [2, 3, 5, 7]:
            if x // a == 0:
                break
            else:
                c = dfs(x // a, memo)
                if c == 0:
                    can_win = True
        if can_win:
            memo[x] = 1
            return 1
        else:
            memo[x] = 0
            return 0
    
    memo = {}
    for n in n_list:
        ans = dfs(n - 1, memo)
        if ans == 1:
            print("sepa")
        else:
            print("ryota")














if __name__ == "__main__":
    main()
0