# How to prove perm-power is in P?

Let $\mathit{PERM\text{-}POWER} = \{ \langle p, q, t\rangle \mid p = q^t \}$ where $p$ and $q$ are permutations on $\{1, \ldots, k\}$ and $t$ is a binary integer. How do I prove that $\mathit{PERM\text{-}POWER}$ is in P?

-

Computing the $t$th power of a permutation is as simple as writing the permutation as a product of disjoint cycles (clearly doable in polynomial time), computing the $t$ modulo each cycle length (also clearly polynomial in the length of $t$, say by grade-school division bit for bit), and iterating each cycle remainder number of times (polynomial even if you don't try to be smart about it, because the remainder will be smaller than $k$, so there are $O(k^2)$ operations even for naive iteration). Finally compose the iterated cycles (again using $O(k^2)$ operations when doing it naively).

-