A. Divisibility
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 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()
{
__int64 k,a,b,count;
while(scanf("%I64d%I64d%I64d",&k,&a,&b)!=EOF)
{
if(a<=0&&b>=0)
count=-a/k+b/k+1;
else if(a<=0&&b<=0)
{
a=-a;b=-b;
count=a/k-b/k;
if(b%k==0) count++;
}
else
{ count= b/k-a/k; if(a%k==0) count++;}
printf("%I64d\n",count);
}
return 0;
}