Divisibility
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard outputFind 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 thata ≤ x ≤ b and x is divisible by k.
Input
The only line contains three space-separated integers k, a and b (1 ≤ k ≤ 1018; - 1018 ≤ a ≤ b ≤ 1018).
Output
Print the required number.
Examples
input
1 1 10
output
10
input
2 -4 4
output
5
#include<stdio.h>
int main()
{
long long a,b,k,ans;
while(scanf("%lld%lld%lld",&k,&a,&b)!=EOF)
{
if(a<=0&&b<=0)
{
long long c;
c=-a;
a=-b;
b=c;
}
if(a<=0&&b>=0)
{
a=-a;
ans=b/k+a/k+1;
}
else
ans=b/k-(a-1)/k;
printf("%lld\n",ans);
}
return 0;
}