Problem I. discrete logarithm problem
时间限制 1500 ms
内存限制 256 MB
You are given three integers $p, a, b$, where $p$ is a prime number and $p-1$ only has prime factors $2$ and/or $3$. Please find the minimum positive integer $x$ such that $a^x \equiv b \pmod{p}$.
输入数据
输出数据
For each test, output a line containing an integer $x$, representing the minimum positive value such that $a^x \equiv b \pmod{p}$. If there didn't exist any such number $x$, please output $-1$.
样例输入
复制
6
65537 2 3
65537 2 4
65537 3 4
65537 4 4
65537 5 4
666334875701477377 2 3
样例输出
复制
-1
2
45056
1
36864
1957714645490451
$ Mathjax font initiator $