Блог пользователя FayedAnik_

Автор FayedAnik_, история, 6 лет назад, По-английски

Hi!every one! I am stuck in this problem https://www.spoj.com/problems/PON/ ! I am trying to solve it with miller rabin primality test. But got tle :-( my solution can be found here https://ideone.com/eSoJpz Can anyone help ? thanks in advance :-)

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится

»
6 лет назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

In your fastexpo(), you should consider using your multiply() when multiplying two numbers. Because say you are doing a * b % MOD, here all of these numbers can big as big as 1018 which will surely cause overflow.