Iterated Linear Function
Submit solution
Points:
100
Time limit:
2.0s
Memory limit:
64M
Author:
Problem types
Allowed languages
Ada, Assembly, Awk, BrainF***, C, C#, C++, Dart, Go, Java, JS, Kotlin, Lua, Pascal, Perl, Prolog, Python, Scala, Swift, VB
Consider a linear function \(f(x) = Ax + B\). Let's define \(g^{(0)}(x) = x\) and \(g^{(n)}(x) = f(g^{(n - 1)}(x))\) for \(n > 0\). For the given integer values and
find the value of
modulo \(10^9 + 7\).
Input Specification
One line whit number of test cases
Each of
lines contains four integers
and \(x (1 \le A, B, x \le 10^9, 1 \le n \le 10^{18})\) — the parameters from the problem statement.
Output Specification
Print one integer per line — the value
modulo \(10^9 + 7\).
Sample input 1
3
3 4 1 1
3 4 2 1
3 4 3 1
Sample output 1
7
25
79
Comments
Ya ahora sí da accepted, gracias
Tengo una solución AC de este exx en codeforces, la unica diferencia es que en el CF la entrada no es por casos de prueba. Mi solución trabaja en log(N) y eso debe pinchar. Me gustaría q comprobaran los juegos de datos. Hay un solo envío accepted q es el del q puso el problema. De no haber error disculpen las molestias.
Ya se arregló. Gracias por avisar.