#K42242. Contiguous Pizza Slices Selection
Contiguous Pizza Slices Selection
Contiguous Pizza Slices Selection
Given a circular pizza with n slices, your task is to count the number of different ways to select k contiguous slices from it, and then output the result modulo x. In a circular arrangement, every slice can serve as the starting point for a contiguous block, so the total number of ways is n (assuming the configuration allows a contiguous block).
The answer is computed using the formula:
$$ answer = n \mod x $$
Read the input from stdin and write the result to stdout.
inputFormat
The input consists of a single line containing three integers: n
(the number of slices), k
(the number of contiguous slices to select), and x
(the modulus), separated by spaces.
outputFormat
Output a single integer: the number of ways to select k
contiguous slices from the pizza, computed as n mod x
.
7 3 1000000007
7