#P1712. GeometricSum
GeometricSum
Compute (a + a^2 + … + a^n) mod m.<nobr style="border:0px;padding:0px;margin:0px;max-width:none;max-height:none;vertical-align:0px;">(a+a2+…an)mod</nobr>
Input
Three integers a,n,m.
(1≤a,n,m≤10^18)
It ends with EOF.
(1≤a,n,m≤10^18)
It ends with EOF.
Output
The only integer denotes the result.
Sample Input
2 2 1000000000
Sample Output
6