#P11495. X-2019 Experiment Measurement Pairs

    ID: 13580 Type: Default 1000ms 256MiB

X-2019 Experiment Measurement Pairs

X-2019 Experiment Measurement Pairs

On planet X-2019, scientists plan a crucial experiment using a research module. Two measurements will be carried out: a primary measurement and a control measurement. Each measurement lasts exactly 1 hour and must start at the beginning of an hour after the research module is activated.

After each measurement, the data is transmitted immediately to an orbital station. The communication channel with the orbital station is established between hours \(l\) and \(r\) after the module begins operating. According to the experimental plan, between the two measurements, the planet must complete an integer number of full rotations. The planet completes one full rotation in \(a\) hours.

If the measurements are taken at hours \(i\) and \(j\) respectively, they must satisfy:

\( l \leq i < j \leq r \) and \( a \mid (j - i) \).

Your task is to count the number of valid measurement pairs \((i, j)\) that meet these constraints.

inputFormat

The input consists of three integers (l), (r), and (a) separated by spaces.

outputFormat

Output a single integer representing the number of valid measurement pairs ((i, j)).

sample

1 10 2
20