結果
問題 | No.1409 Simple Math in yukicoder |
ユーザー |
![]() |
提出日時 | 2021-02-26 22:18:01 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 990 ms / 2,000 ms |
コード長 | 658 bytes |
コンパイル時間 | 436 ms |
コンパイル使用メモリ | 82,020 KB |
実行使用メモリ | 181,156 KB |
最終ジャッジ日時 | 2024-10-02 15:07:51 |
合計ジャッジ時間 | 63,477 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 58 |
ソースコード
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)]))