結果

問題 No.1409 Simple Math in yukicoder
ユーザー 👑 KazunKazun
提出日時 2021-02-26 23:06:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 129 ms / 2,000 ms
コード長 1,050 bytes
コンパイル時間 209 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 77,676 KB
最終ジャッジ日時 2024-04-10 14:07:05
合計ジャッジ時間 31,380 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
52,320 KB
testcase_01 AC 40 ms
53,820 KB
testcase_02 AC 38 ms
52,400 KB
testcase_03 AC 39 ms
53,764 KB
testcase_04 AC 38 ms
54,024 KB
testcase_05 AC 37 ms
53,560 KB
testcase_06 AC 38 ms
52,588 KB
testcase_07 AC 60 ms
66,452 KB
testcase_08 AC 98 ms
76,748 KB
testcase_09 AC 62 ms
65,980 KB
testcase_10 AC 94 ms
76,308 KB
testcase_11 AC 98 ms
76,800 KB
testcase_12 AC 95 ms
76,876 KB
testcase_13 AC 61 ms
66,688 KB
testcase_14 AC 57 ms
65,408 KB
testcase_15 AC 63 ms
67,712 KB
testcase_16 AC 65 ms
67,968 KB
testcase_17 AC 105 ms
77,056 KB
testcase_18 AC 89 ms
77,056 KB
testcase_19 AC 95 ms
76,864 KB
testcase_20 AC 87 ms
76,592 KB
testcase_21 AC 87 ms
76,512 KB
testcase_22 AC 95 ms
77,056 KB
testcase_23 AC 57 ms
64,896 KB
testcase_24 AC 53 ms
63,232 KB
testcase_25 AC 95 ms
77,056 KB
testcase_26 AC 100 ms
76,872 KB
testcase_27 AC 109 ms
76,728 KB
testcase_28 AC 105 ms
76,784 KB
testcase_29 AC 109 ms
76,556 KB
testcase_30 AC 107 ms
76,928 KB
testcase_31 AC 109 ms
76,516 KB
testcase_32 AC 110 ms
77,056 KB
testcase_33 AC 103 ms
76,800 KB
testcase_34 AC 105 ms
77,052 KB
testcase_35 AC 109 ms
76,904 KB
testcase_36 AC 109 ms
77,008 KB
testcase_37 AC 116 ms
76,800 KB
testcase_38 AC 119 ms
77,056 KB
testcase_39 AC 113 ms
77,544 KB
testcase_40 AC 116 ms
77,440 KB
testcase_41 AC 120 ms
77,312 KB
testcase_42 AC 122 ms
77,568 KB
testcase_43 AC 120 ms
77,184 KB
testcase_44 AC 115 ms
77,676 KB
testcase_45 AC 120 ms
77,552 KB
testcase_46 AC 125 ms
77,440 KB
testcase_47 AC 119 ms
77,184 KB
testcase_48 AC 123 ms
77,348 KB
testcase_49 AC 120 ms
77,172 KB
testcase_50 AC 119 ms
77,184 KB
testcase_51 AC 128 ms
77,056 KB
testcase_52 AC 119 ms
77,536 KB
testcase_53 AC 117 ms
77,568 KB
testcase_54 AC 125 ms
77,356 KB
testcase_55 AC 122 ms
77,412 KB
testcase_56 AC 121 ms
76,932 KB
testcase_57 AC 129 ms
77,364 KB
testcase_58 AC 124 ms
77,012 KB
testcase_59 AC 121 ms
77,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def Primitive_Root(p):
    """Z/pZ上の原始根を見つける

    p:素数
    """
    if p==2:
        return 1
    if p==998244353:
        return 3
    if p==10**9+7:
        return 5
    if p==163577857:
        return 23
    if p==167772161:
        return 3
    if  p==469762049:
        return 3

    fac=[]
    q=2
    v=p-1

    while v>=q*q:
        e=0
        while v%q==0:
            e+=1
            v//=q

        if e>0:
            fac.append(q)
        q+=1

    if v>1:
        fac.append(v)

    g=2
    while g<p:
        if pow(g,p-1,p)!=1:
            return None

        flag=True
        for q in fac:
            if pow(g,(p-1)//q,p)==1:
                flag=False
                break

        if flag:
            return g

        g+=1
#================================================
T=int(input())

for _ in range(T):
    v,x=map(int,input().split())
    p=v*x+1
    g=Primitive_Root(p)
    r=pow(g,v,p)

    A=[]
    a=1
    for __ in range(x):
        A.append(a)
        a=(a*r)%p

    A.sort()
    print(*A)
0