Divisibility

来源:互联网 发布:弹弹play mac 编辑:程序博客网 时间:2024/06/05 11:37

点击打开链接

Find the number of k-divisible numbers on the segment [a, b]. In other words you need to find the number of such integer values x that a ≤ x ≤ b and x is divisible by k.

Input

The only line contains three space-separated integers ka and b (1 ≤ k ≤ 1018; - 1018 ≤ a ≤ b ≤ 1018).

Output

Print the required number.

Example
Input
1 1 10
Output
10
Input
2 -4 4
Output
5



代码:

#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
#define ll long long
int main()
{
    ll k,a,b;
    scanf("%lld%lld%lld",&k,&a,&b);
    if(a<=0&&b>=0)
        printf("%lld\n",(b/k)-(a/k)+1);
    else if(a>=0&&b>=0)
        printf("%lld\n",(b/k)-(a/k+(a%k?1:0))+1);
    else
        printf("%lld\n",(abs(a)/k)-(abs(b)/k+(abs(b)%k?1:0))+1);//abs取绝对值 
    return 0;
}