Problem:
Score : 200 points

Problem Statement

You are given nonnegative integers a and b (a ≤ b), and a positive integer x.
Among the integers between a and b, inclusive, how many are divisible by x?

Constraints

0 ≤ a ≤ b ≤ 10^{18}

1 ≤ x ≤ 10^{18}

Input

The input is given from Standard Input in the following format:

a b x

Output

Print the number of the integers between a and b, inclusive, that are divisible by x.

Sample Input 1

4 8 2

Sample Output 1

3

There are three integers between 4 and 8, inclusive, that are divisible by 2: 4, 6 and 8.

Sample Input 2

0 5 1

Sample Output 2

6

There are six integers between 0 and 5, inclusive, that are divisible by 1: 0, 1, 2, 3, 4 and 5.

Sample Input 3

9 9 2

Sample Output 3

0

There are no integer between 9 and 9, inclusive, that is divisible by 2.

Sample Input 4

1 1000000000000000000 3

Sample Output 4

333333333333333333

Watch out for integer overflows.

Solution in Rust (1.15.1) (judge verdict: Accepted)

use std::io::prelude::*;
use std::io;
use std::str::FromStr;
#[cfg(local)]
use std::fs::File;
#[cfg(local)]
use std::io::BufReader;

#[cfg(local)]
fn buf_read() -> io::Result<(Vec<String>)> {
    let f = try!(File::open("input.txt"));
    let input_lines: Vec<_> = BufReader::new(f).lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

#[cfg(not(local))]
fn buf_read() -> io::Result<(Vec<String>)> {
    let stdin = io::stdin();
    let input_lines: Vec<_> = stdin.lock().lines().collect();
    let lines: Vec<String> = input_lines.into_iter().map(|e| e.unwrap()).collect();
    Ok((lines))
}

fn main() {
    type Element = i64;
    let input = buf_read().unwrap();
    let mut input_vectors: Vec<Vec<Element>> = vec![];
    for input_line in input {
        let input_str: Vec<String> = input_line.split(' ').map(String::from).collect();
        let mut input_vector: Vec<Element> = vec![];
        for input_elem_str in input_str {
            let elem: Element = Element::from_str(input_elem_str.as_str()).unwrap();
            input_vector.push(elem);
        }
        input_vectors.push(input_vector);
    }
    let a = if input_vectors[0][0] == 0 {
        0
    } else {
        input_vectors[0][0] - 1
    };
    let b = input_vectors[0][1];
    let x = input_vectors[0][2];
    let b_quotient = b / x;
    // let a_quotient = (a - 1) / x;
    let a_quotient = a / x;
    let ans = if input_vectors[0][0] != 0 {
        b_quotient - a_quotient
    } else {
        b_quotient - a_quotient + 1
    };
    println!("{}", ans);
    // println!("{}", b_quotient - a_quotient);
    // println!("{}", 0 / 1);
}