結果
| 問題 |
No.1409 Simple Math in yukicoder
|
| コンテスト | |
| ユーザー |
GER_chen
|
| 提出日時 | 2021-02-27 14:58:54 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 159 ms / 2,000 ms |
| コード長 | 745 bytes |
| コンパイル時間 | 165 ms |
| コンパイル使用メモリ | 82,316 KB |
| 実行使用メモリ | 77,036 KB |
| 最終ジャッジ日時 | 2024-10-02 17:29:48 |
| 合計ジャッジ時間 | 31,931 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 58 |
ソースコード
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)]))
GER_chen