杂题

题意

给定长度为\(n\)的序列\(a_i\)\(q\)次询问,给定\((l,r)\),求\(a_l^{a_{l+1}^{a_{l+2}^{\cdots a_r}}}\)

做法

扩展欧拉定理

  • \(a^b\equiv a^b(mod~p)(b<\phi(p))\)
  • \(a^b\equiv a^{b\%\phi(p)+\phi(p)}(mod~p)(b\ge \phi(p))\)

\(p\longrightarrow \phi(p)\longrightarrow \phi(\phi(p))\),有效变化是\(O(logp)\)

posted @ 2020-05-30 10:59  Grice  阅读(73)  评论(0编辑  收藏  举报