Sum of products#1138

Sum of products

3 segundos
64 megabytes
Fácil

Given natural numbers , , and , your task is to compute the following sum of products:

a \cdot (a + 1) \cdot \ldots \cdot (a + n - 1) + (a + 1) \cdot (a + 2) \cdot \ldots \cdot (a + n) + \ldots + b \cdot (b + 1) \cdot \ldots \cdot (b + n - 1)

Since the result can be extremely large, you need to find the remainder of this sum when divided by .

Entrada

The input consists of a single line containing the natural numbers , , and (a \leq b \leq 10^{18}, b - a \leq 10^7, and n \leq 10^7).

Salida

Output the computed sum of products modulo .

Ejemplos

Ejemplo 1

Loading
Loading