d017: 習題 Q-2-8. 模逆元 (*)
Tags : fermat's little theorem math modular modular inverse
Accepted rate : 164人/167人 ( 98% ) [非即時]
評分方式:
Tolerant

最近更新 : 2022-03-18 11:12

Content

輸入 $n$ 個正整數,以及一個質數 $P$,請計算每一個輸入數的模逆元。輸入的正整數的大小不超過 $P$,$P \leq 1000000009$,$0 < n < 10$。

Input

第一行是 $n$ 與 $P$,

第二行 $n$ 個整數,

同行數字以空白間隔。

Output

依照輸入順序輸出每一個數的模逆元,相鄰數字間間隔一個空白。

Sample Input #1
3 7
3 4 1
Sample Output #1
5 2 1
測資資訊:
記憶體限制: 64 MB
公開 測資點#0 (20%): 1.0s , <1K
公開 測資點#1 (20%): 1.0s , <1K
公開 測資點#2 (20%): 1.0s , <1K
公開 測資點#3 (20%): 1.0s , <1K
公開 測資點#4 (20%): 1.0s , <1K
Hint :
Tags:
fermat's little theorem math modular modular inverse
出處:
AP325 [管理者:
TCIRC ($\mathbb{TCFSH}\ \mathtt{Comp.}\ \&\ \mathsf{Info.}\ \mathit{Club}$)
]


ID User Problem Subject Hit Post Date
沒有發現任何「解題報告」