Question: Calculate the remainder when p^(q!) is divided by r.

Правка en1, от thopecoder, 2020-08-12 15:14:02

Given three integers p,q,r. You have calculate remainder when $$$p^{(q!)}$$$ is divided by r. where '!' is factorial.

basically $$$p^{(q!)}$$$%r

constraints: 1 <= p,q,r <= 10^5

I have tried using naive factorization with binary exponentiation. Is there a more optimized approach for this problem?

Теги #modular exponentiation, factorization, #algorithms, #optimization

История

 
 
 
 
Правки
 
 
  Rev. Язык Кто Когда Δ Комментарий
en1 Английский thopecoder 2020-08-12 15:14:02 363 Initial revision (published)