結果
問題 | No.1409 Simple Math in yukicoder |
ユーザー |
![]() |
提出日時 | 2021-02-26 22:15:44 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 158 ms / 2,000 ms |
コード長 | 1,163 bytes |
コンパイル時間 | 301 ms |
コンパイル使用メモリ | 82,044 KB |
実行使用メモリ | 76,716 KB |
最終ジャッジ日時 | 2024-10-02 15:05:08 |
合計ジャッジ時間 | 31,344 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 58 |
ソースコード
import syssys.setrecursionlimit(10**7)def I(): return int(sys.stdin.readline().rstrip())def MI(): return map(int,sys.stdin.readline().rstrip().split())def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))def LI2(): return list(map(int,sys.stdin.readline().rstrip()))def S(): return sys.stdin.readline().rstrip()def LS(): return list(sys.stdin.readline().rstrip().split())def LS2(): return list(sys.stdin.readline().rstrip())def min_primitive_root(p): # 素数pの最小の原始根if p == 2:return 1n = p-1prime_list = [] # n の素因数for i in range(2,int(n**.5)+1):if n % i == 0:prime_list.append(i)while n % i == 0:n //= iif n != 1:prime_list.append(n)a = 2 # 原始根の候補n = p-1while True:for prime in prime_list:if pow(a,n//prime,p) == 1:a += 1breakelse:return aT = I()for _ in range(T):v,x = MI()p = x*v+1r = min_primitive_root(p)ANS = [pow(r,v*i,p) for i in range(1,x+1)]ANS.sort()print(*ANS)