結果

問題 No.1409 Simple Math in yukicoder
ユーザー convexineqconvexineq
提出日時 2021-02-27 07:07:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 189 ms / 2,000 ms
コード長 750 bytes
コンパイル時間 232 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 77,448 KB
最終ジャッジ日時 2024-04-10 15:13:21
合計ジャッジ時間 33,125 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,224 KB
testcase_01 AC 40 ms
52,468 KB
testcase_02 AC 39 ms
52,480 KB
testcase_03 AC 39 ms
52,224 KB
testcase_04 AC 39 ms
52,992 KB
testcase_05 AC 39 ms
52,864 KB
testcase_06 AC 38 ms
52,480 KB
testcase_07 AC 66 ms
67,456 KB
testcase_08 AC 119 ms
76,800 KB
testcase_09 AC 67 ms
66,944 KB
testcase_10 AC 106 ms
76,624 KB
testcase_11 AC 123 ms
77,056 KB
testcase_12 AC 106 ms
76,544 KB
testcase_13 AC 68 ms
67,456 KB
testcase_14 AC 62 ms
65,536 KB
testcase_15 AC 73 ms
69,888 KB
testcase_16 AC 73 ms
68,864 KB
testcase_17 AC 137 ms
76,812 KB
testcase_18 AC 96 ms
76,424 KB
testcase_19 AC 105 ms
76,928 KB
testcase_20 AC 95 ms
73,728 KB
testcase_21 AC 80 ms
71,680 KB
testcase_22 AC 106 ms
76,580 KB
testcase_23 AC 60 ms
64,384 KB
testcase_24 AC 55 ms
64,000 KB
testcase_25 AC 106 ms
76,672 KB
testcase_26 AC 113 ms
76,912 KB
testcase_27 AC 143 ms
77,112 KB
testcase_28 AC 143 ms
76,900 KB
testcase_29 AC 147 ms
76,808 KB
testcase_30 AC 142 ms
76,700 KB
testcase_31 AC 148 ms
76,672 KB
testcase_32 AC 145 ms
77,104 KB
testcase_33 AC 142 ms
77,012 KB
testcase_34 AC 143 ms
76,848 KB
testcase_35 AC 151 ms
76,800 KB
testcase_36 AC 145 ms
77,184 KB
testcase_37 AC 175 ms
76,884 KB
testcase_38 AC 175 ms
77,056 KB
testcase_39 AC 179 ms
77,184 KB
testcase_40 AC 181 ms
77,448 KB
testcase_41 AC 179 ms
76,928 KB
testcase_42 AC 176 ms
77,300 KB
testcase_43 AC 182 ms
77,184 KB
testcase_44 AC 186 ms
76,856 KB
testcase_45 AC 178 ms
76,820 KB
testcase_46 AC 189 ms
77,388 KB
testcase_47 AC 187 ms
77,296 KB
testcase_48 AC 180 ms
76,928 KB
testcase_49 AC 178 ms
76,752 KB
testcase_50 AC 176 ms
77,016 KB
testcase_51 AC 178 ms
77,376 KB
testcase_52 AC 177 ms
77,056 KB
testcase_53 AC 176 ms
77,056 KB
testcase_54 AC 175 ms
76,928 KB
testcase_55 AC 179 ms
76,872 KB
testcase_56 AC 180 ms
77,440 KB
testcase_57 AC 178 ms
77,044 KB
testcase_58 AC 183 ms
77,056 KB
testcase_59 AC 177 ms
76,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def prime_factors(N): #素因数のリスト
    factors = []
    if N&1==0:
        factors = [2]
        while N%2 == 0: N //= 2
    else: factorization = []
    M = int(N**0.5)+1
    for i in range(3,M,2):
        if N%i==0:
            while N%i == 0: N //= i
            factors.append(i)
    if N!= 1: factors.append(N)
    assert N != 0, "zero"
    return factors

def solve(v,x):
    p = v*x+1
    ps = prime_factors(v)+prime_factors(x)
    r = 1
    for r in range(2,p):
        for pp in ps:
            if pow(r,v*x//pp,p) == 1:
                break
        else:
            break
    a = [pow(r,i*v,p) for i in range(x)]
    return sorted(a)

T = int(input())
for _ in range(T):
    v,x = map(int,input().split())
    print(*solve(v,x))
0