結果

問題 No.1409 Simple Math in yukicoder
ユーザー LyricalMaestro
提出日時 2025-07-06 01:12:32
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 744 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 81,916 KB
実行使用メモリ 77,636 KB
最終ジャッジ日時 2025-07-06 01:13:33
合計ジャッジ時間 34,955 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 22 TLE * 13 -- * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def solve(v, x):
    if x == 1:
        return 1

    p = x * v + 1
    answer = []
    for r in range(2, p):
        w = r
        a_set = set()
        while w not in a_set:
            a_set.add(w)
            w *= r
            w %= p
            if len(a_set) > x:
                break
        if len(a_set) == x:
            answer = list(a_set)
            break
    
    answer.sort()
    return " ".join(map(str, answer))





def main():
    T = int(input())
    answers = []
    for _ in range(T):
        v, x = map(int, input().split())
        ans = solve(v, x)
        answers.append(ans)
    for ans in answers:
        print(ans)









    



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