http://www.lydsy.com/JudgeOnline/problem.php?id=2875
题意:给出mod,a,c,g,x0,n,xn=(a*xn-1+c)%mod,求xn%g
求A*B^n,注意乘法要用慢速乘。