結果

問題 No.1409 Simple Math in yukicoder
ユーザー GER_chen
提出日時 2021-02-27 15:08:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 523 bytes
コンパイル時間 354 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 77,172 KB
最終ジャッジ日時 2024-10-02 17:54:14
合計ジャッジ時間 16,416 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 7 WA * 51
権限があれば一括ダウンロードができます

ソースコード

diff #

def p(m):
    if m==2:
        return 1
    D,x=[2],(m-1)//2
    while x&1:
        x//=2
    i=3
    while i*i<=x:
        if not x%i:
            D.append(i)
            while not x%i:
                x//=i
        i+=2
    if x>1:
        D.append(x)
    g=2
    while True:
        if all(pow(g,(m-1)//d,m)!= 1for d in D):
            return g
        g+=1
                
for _ in range(int(input())):
    v,x=map(int,input().split())
    q=v*x+1
    h=pow(p(q),v,q)
    print(*sorted([pow(h,i,q) for i in range(x)]))
0