Give me some tips to solve- uva 10692 problem.. - problem link:https://uva.onlinejudge.org/external/106/10692.pdf
№ | Пользователь | Рейтинг |
---|---|---|
1 | tourist | 4009 |
2 | jiangly | 3823 |
3 | Benq | 3738 |
4 | Radewoosh | 3633 |
5 | jqdai0815 | 3620 |
6 | orzdevinwang | 3529 |
7 | ecnerwala | 3446 |
8 | Um_nik | 3396 |
9 | ksun48 | 3390 |
10 | gamegame | 3386 |
Страны | Города | Организации | Всё → |
№ | Пользователь | Вклад |
---|---|---|
1 | cry | 167 |
2 | Um_nik | 163 |
3 | maomao90 | 162 |
3 | atcoder_official | 162 |
5 | adamant | 159 |
6 | -is-this-fft- | 158 |
7 | awoo | 157 |
8 | TheScrasse | 154 |
9 | Dominater069 | 153 |
9 | nor | 153 |
Give me some tips to solve- uva 10692 problem.. - problem link:https://uva.onlinejudge.org/external/106/10692.pdf
Название |
---|
A ^ x % m = A ^ (x % phi [M] + phi [M]) % m (x >= phi [M])
(phi [M] M is the Euler function)you can recursively go to solution.
Why do we need to sum up
phi[M]
inA ^ (x % phi [M] + phi [M]) % m
? Isn'tA ^ (x % phi[M]) % m
good enough?In case
x % φ[M]
is equal to0
,A^0 % M
will become one, which may not be same asA^φ{M} % M
e.g. (2 ^ 0) % 10 = 1, (2 ^ 4) % 10 = 6, phi[10] = 4;
Thanks.. if u explain How/Why its works?
it is necessary to dfs like that
Can you or someone else please reply why this equation works? Is this true for any A and m ?
Here's the AC code may help you, be careful that we should test if b in ab is greater than φ(m)