Олимпиадный тренинг

Задача 33144. Two dimensions


Задача

Темы: Вывод формулы
Scientists plan to conduct an important experiment using the research module
on planet X-2019. During the experiment, two measurements will be taken: the main and the control.
Each measurement takes exactly one hour and must start an integer number of hours after
start of the research module.
The data of the experiment is planned to be immediately transferred to the orbital station. Communication channel
with the orbital station will be installed from the l-th to the r-th hour from the start of the research module, inclusive. In addition, according to the plan of the experiment between measurements, the planet
must make an integer number of revolutions around its axis. Planet X-2019 turns around
around its axis in a hours.
Thus, if the measurements are carried out at the i-th and j-th hour, then the inequality l <= i < j <= r, and the value (j < minus; i) must be a multiple of a. Now scientists need to understand
how many different ways to take measurements.
It is required to write a program that, given the limits of the measurement time l and r and the period of revolution of the planet around its axis a, determines the number of possible ways to spend
measurements: number of pairs of integers i and j such that l <= i < j <= r and the value (j − i) is a multiple of a.

Input data format
The input contains three integers, one per line: l, r, and a (1 <= l < r <= 109,1 <= a <= 109).
Output format
Print one integer: the number of ways to measure.

Enter Output
1
5
2
4
4
9
6
0

Explanations for examples
In the first example, you can take measurements at the following pairs of hours: (1, 3), (1, 5), (2, 4), (3, 5).
In the second example, the duration of the communication channel is not enough to spend two
measurements.