結果

問題 No.1409 Simple Math in yukicoder
ユーザー GER_chenGER_chen
提出日時 2021-02-26 22:18:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 872 ms / 2,000 ms
コード長 658 bytes
コンパイル時間 365 ms
コンパイル使用メモリ 82,436 KB
実行使用メモリ 181,356 KB
最終ジャッジ日時 2024-04-10 13:04:52
合計ジャッジ時間 54,817 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
56,188 KB
testcase_01 AC 38 ms
56,664 KB
testcase_02 AC 38 ms
55,872 KB
testcase_03 AC 38 ms
55,024 KB
testcase_04 AC 41 ms
55,800 KB
testcase_05 AC 40 ms
55,568 KB
testcase_06 AC 38 ms
55,436 KB
testcase_07 AC 223 ms
105,548 KB
testcase_08 AC 609 ms
147,176 KB
testcase_09 AC 214 ms
100,940 KB
testcase_10 AC 500 ms
127,000 KB
testcase_11 AC 594 ms
134,028 KB
testcase_12 AC 476 ms
125,524 KB
testcase_13 AC 233 ms
104,420 KB
testcase_14 AC 198 ms
97,852 KB
testcase_15 AC 270 ms
106,596 KB
testcase_16 AC 274 ms
107,276 KB
testcase_17 AC 774 ms
147,000 KB
testcase_18 AC 422 ms
113,356 KB
testcase_19 AC 448 ms
123,464 KB
testcase_20 AC 378 ms
108,636 KB
testcase_21 AC 317 ms
107,028 KB
testcase_22 AC 529 ms
131,064 KB
testcase_23 AC 155 ms
90,292 KB
testcase_24 AC 129 ms
85,216 KB
testcase_25 AC 513 ms
122,028 KB
testcase_26 AC 566 ms
134,592 KB
testcase_27 AC 872 ms
155,148 KB
testcase_28 AC 816 ms
142,416 KB
testcase_29 AC 817 ms
143,788 KB
testcase_30 AC 858 ms
147,388 KB
testcase_31 AC 856 ms
146,272 KB
testcase_32 AC 782 ms
146,608 KB
testcase_33 AC 820 ms
153,796 KB
testcase_34 AC 837 ms
145,928 KB
testcase_35 AC 851 ms
142,328 KB
testcase_36 AC 843 ms
152,532 KB
testcase_37 AC 757 ms
175,200 KB
testcase_38 AC 755 ms
179,540 KB
testcase_39 AC 752 ms
176,616 KB
testcase_40 AC 761 ms
178,744 KB
testcase_41 AC 763 ms
180,588 KB
testcase_42 AC 766 ms
181,192 KB
testcase_43 AC 772 ms
178,748 KB
testcase_44 AC 763 ms
174,556 KB
testcase_45 AC 752 ms
173,696 KB
testcase_46 AC 745 ms
181,292 KB
testcase_47 AC 740 ms
176,264 KB
testcase_48 AC 795 ms
181,200 KB
testcase_49 AC 764 ms
177,132 KB
testcase_50 AC 755 ms
176,544 KB
testcase_51 AC 751 ms
178,180 KB
testcase_52 AC 752 ms
176,436 KB
testcase_53 AC 749 ms
174,776 KB
testcase_54 AC 758 ms
175,840 KB
testcase_55 AC 751 ms
180,396 KB
testcase_56 AC 808 ms
181,356 KB
testcase_57 AC 205 ms
95,056 KB
testcase_58 AC 196 ms
95,120 KB
testcase_59 AC 198 ms
95,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
@lru_cache(maxsize = None)
def prim(p):
    if p in {2, 3}:
        return p-1
    Cand = [True for _ in range(p)]
    Cand[0], Cand[1] = False, False
    for i in range(2, p):
        if Cand[i]:
            Cand[i] = False
            ct, exp = 1, i
            while exp != 1:
                exp *= i
                exp %= p
                Cand[exp] = False
                ct += 1
            if ct == p-1:
                return i
                
for _ in range(int(input())):
    v, x = map(int, input().split())
    q = v*x+1
    g = prim(q)
    h = pow(g, v, q)
    print(*sorted([pow(h, i, q) for i in range(x)]))
0