Hi everyone,
(131015-1) / (13-1)
I want to calculate the previous value modulo 36 in an efficient way, how can I do that?
| № | Пользователь | Рейтинг |
|---|---|---|
| 1 | Benq | 3792 |
| 2 | VivaciousAubergine | 3647 |
| 3 | Kevin114514 | 3603 |
| 4 | jiangly | 3583 |
| 5 | turmax | 3559 |
| 6 | tourist | 3541 |
| 7 | strapple | 3515 |
| 8 | ksun48 | 3461 |
| 9 | dXqwq | 3436 |
| 10 | Otomachi_Una | 3413 |
| Страны | Города | Организации | Всё → |
| № | Пользователь | Вклад |
|---|---|---|
| 1 | Qingyu | 157 |
| 2 | adamant | 153 |
| 3 | Um_nik | 147 |
| 4 | Proof_by_QED | 146 |
| 5 | Dominater069 | 145 |
| 6 | errorgorn | 142 |
| 7 | cry | 139 |
| 8 | YuukiS | 135 |
| 9 | TheScrasse | 134 |
| 10 | chromate00 | 133 |
Hi everyone,
(131015-1) / (13-1)
I want to calculate the previous value modulo 36 in an efficient way, how can I do that?
| Название |
|---|



Can you provide a link to the problem?
Sorry it is not a CP problem, I know how to calculate the inverse modulo but in this case the denominator (13-1 = 12) and the modulo 36 are not coprime, so I am not sure how to do the calculation in a fast way and without an overflow happening
Here
Thanks for the reply, but my problem is in the division by 12, will this solve my problem?
$$$(13^{10^{15}}-1) = (13-1)(13^{10^{15}-1}+13^{10^{15}-2}+...+13^1+1)$$$
$$$(13^{10^{15}}-1)/(13-1)= (13^{10^{15}-1}+13^{10^{15}-2}+...+13^1+1)$$$
$$$13^n \mod 36 = \begin{cases} 1(n \equiv 0 \mod 3) \\ 13(n \equiv 1 \mod 3) \\ 25(n \equiv 2 \mod 3) \end{cases}$$$
Then, you can just sum up this.
Thank you so much, this is an awesome solution. How to generalize it to find
(an-1)/(a-1) mod m ?
If m is small(<=10^6), you can try above approach (to find a cycle of a^k mod m) in O(m). Or, using modular inverse if you can. I don't have further idea, sorry...
Thank you so much