結果

問題 No.1409 Simple Math in yukicoder
ユーザー ygd.
提出日時 2021-02-26 22:53:24
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 507 ms / 2,000 ms
コード長 430 bytes
コンパイル時間 424 ms
コンパイル使用メモリ 82,304 KB
実行使用メモリ 77,240 KB
最終ジャッジ日時 2024-10-02 15:37:23
合計ジャッジ時間 41,256 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 58
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
    v,x = map(int,input().split())
    p = v*x + 1
    for i in reversed(range(1,p+1)):
        if pow(i,x,p) != 1:
            continue
        S = set([])
        S.add(i)
        ni = i*i%p
        while ni not in S:
            S.add(ni)
            ni = ni*i%p
        #print(i,S)
        if len(S) == x:
            L = list(S)
            L.sort()
            print(*L)
            break
0