#C2473. Count Multiples
Count Multiples
Count Multiples
Given three integers A, B, and K, your task is to calculate the number of multiples of K in the closed interval [A, B]. In other words, find the count of integers x such that A ≤ x ≤ B and K divides x evenly.
You can use the formula: \(\lfloor \frac{B}{K} \rfloor - \lfloor \frac{A-1}{K} \rfloor\) to compute the answer, but you are free to use any correct approach.
For example:
- Input: 6 11 2 → Multiples: 6, 8, 10 so output is 3.
- Input: 1 10 3 → Multiples: 3, 6, 9 so output is 3.
inputFormat
Standard input consists of a single line containing three space-separated integers A, B, and K.
outputFormat
Output a single integer -- the number of multiples of K between A and B (inclusive).
## sample6 11 2
3