Problems > Multiples in a Range

Multiples in a Range

Difficulty: 900 2000 ms 128 MB

math

How many multiples of D lie in [L, R]?

Input: one line with three integers L, R, D.

Output: ⌊R/D⌋ − ⌊(L−1)/D⌋.

Constraints:

  • 1 ≤ L ≤ R ≤ 1018
  • 1 ≤ D ≤ 1018

Sample Tests

Input 1
6 20 5
Output 1
3
Input 2
1 10 1
Output 2
10

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.