Description
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.
Sample Input
Input
1 1 10
Output
10
Input
2 -4 4
Output
5
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28#include<stdio.h> #include<algorithm> using namespace std; int main() { __int64 k,a,b,i; while(scanf("%I64d%I64d%I64d",&k,&a,&b)!=EOF) { __int64 t=0; if(a==0&&b==0) t=1; else { if(b>=0) { t=t+b/k;//1到b中能被k整除的数个数 if(a>0) t-=(a-1)/k;减去1到a-1中能被k整除的数个数 else t+=-a/k+1;加上a到0中能被k整除的数个数 } else t=-a/k-(-b-1)/k; } printf("%I64d\n",t); } return 0; }