turzo_sawroop's blog

By turzo_sawroop, history, 7 months ago, In English

In this problem : https://cses.fi/problemset/task/1712/ modpow(a,modpow(b,c,INF-1),INF)-This Gives Correct Answers. modpow(a,modpow(b,c,INF),INF)-But this gives wrong Answers. But why? What's the mathematical logic??Can anyone please Explain??

  • Vote: I like it
  • 0
  • Vote: I do not like it

7 months ago, # |
  Vote: I like it +13 Vote: I do not like it

due to something known as fermats little theorem that's how it works (raising b^c %(inf-1)). consider googling "fermats little theorem".