結果

問題 No.1409 Simple Math in yukicoder
ユーザー GER_chenGER_chen
提出日時 2021-02-27 14:58:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 166 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 629 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 77,052 KB
最終ジャッジ日時 2024-04-10 15:39:06
合計ジャッジ時間 32,310 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,096 KB
testcase_01 AC 42 ms
52,608 KB
testcase_02 AC 40 ms
52,736 KB
testcase_03 AC 40 ms
52,352 KB
testcase_04 AC 40 ms
52,352 KB
testcase_05 AC 40 ms
52,352 KB
testcase_06 AC 40 ms
51,968 KB
testcase_07 AC 65 ms
65,536 KB
testcase_08 AC 127 ms
76,304 KB
testcase_09 AC 63 ms
65,536 KB
testcase_10 AC 107 ms
76,288 KB
testcase_11 AC 121 ms
76,672 KB
testcase_12 AC 102 ms
76,316 KB
testcase_13 AC 64 ms
66,816 KB
testcase_14 AC 59 ms
64,896 KB
testcase_15 AC 66 ms
68,224 KB
testcase_16 AC 67 ms
68,480 KB
testcase_17 AC 129 ms
76,456 KB
testcase_18 AC 92 ms
76,368 KB
testcase_19 AC 104 ms
76,704 KB
testcase_20 AC 89 ms
76,316 KB
testcase_21 AC 82 ms
74,292 KB
testcase_22 AC 102 ms
76,348 KB
testcase_23 AC 55 ms
64,384 KB
testcase_24 AC 52 ms
63,232 KB
testcase_25 AC 99 ms
76,416 KB
testcase_26 AC 100 ms
76,288 KB
testcase_27 AC 129 ms
76,544 KB
testcase_28 AC 133 ms
76,756 KB
testcase_29 AC 127 ms
76,584 KB
testcase_30 AC 134 ms
76,932 KB
testcase_31 AC 137 ms
76,672 KB
testcase_32 AC 131 ms
77,052 KB
testcase_33 AC 126 ms
76,324 KB
testcase_34 AC 128 ms
76,548 KB
testcase_35 AC 135 ms
76,672 KB
testcase_36 AC 131 ms
76,584 KB
testcase_37 AC 156 ms
76,800 KB
testcase_38 AC 146 ms
76,752 KB
testcase_39 AC 147 ms
76,900 KB
testcase_40 AC 159 ms
76,724 KB
testcase_41 AC 149 ms
76,516 KB
testcase_42 AC 146 ms
76,800 KB
testcase_43 AC 148 ms
76,672 KB
testcase_44 AC 149 ms
76,800 KB
testcase_45 AC 156 ms
76,544 KB
testcase_46 AC 158 ms
76,928 KB
testcase_47 AC 154 ms
76,508 KB
testcase_48 AC 150 ms
76,760 KB
testcase_49 AC 152 ms
76,672 KB
testcase_50 AC 165 ms
76,692 KB
testcase_51 AC 159 ms
76,920 KB
testcase_52 AC 160 ms
76,428 KB
testcase_53 AC 153 ms
76,812 KB
testcase_54 AC 165 ms
76,684 KB
testcase_55 AC 156 ms
76,672 KB
testcase_56 AC 150 ms
76,784 KB
testcase_57 AC 161 ms
76,800 KB
testcase_58 AC 155 ms
76,800 KB
testcase_59 AC 166 ms
76,800 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def primitive_root(m):
    if m == 2: return 1
    if m == 167772161: return 3
    if m == 469762049: return 3
    if m == 754974721: return 11
    if m == 998244353: return 3

    Divs = [2]
    x = (m-1)//2
    while x%2 == 0:
        x //= 2
    i = 3
    while i*i <= x:
        if not x%i:
            Divs.append(i)
            while not x%i:
                x //= i
        i += 2
    if x > 1:
        Divs.append(x)

    g = 2
    while True:
        if all(pow(g, (m-1)//div, m) != 1 for div in Divs):
            return g
        g += 1
                
for _ in range(int(input())):
    v, x = map(int, input().split())
    q = v*x+1
    g = primitive_root(q)
    h = pow(g, v, q)
    print(*sorted([pow(h, i, q) for i in range(x)]))
0