CodeForces 597A Divisibility
R - R
Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u

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 thata ≤ 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.

Sample Input

Input
1 1 10

Output
10

Input
2 -4 4

Output

5

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int main()
{
__int64 k,a,b,ans;
while(scanf("%I64d%I64d%I64d",&k,&a,&b)!=EOF)
{
if(a>0&&b>0)
{
ans=abs(b/k)-abs((a-1)/k);
}
else if(a<0&&b<0)
{
ans=abs(a/k)-abs((b+1)/k);
}
else
{
ans=abs(a/k)+abs(b/k)+1;
}
printf("%I64d\n",ans);
}
return 0;
}

Codeforces 922 div2 d、e、f

2018-02-11 03:48:24

CodeForces-630 J. Divisibility

2016-03-11 22:19:31

【Codeforces 597A】A. Divisibility

2016-07-24 18:13:09

Codeforces 597A： Divisibility（技巧）

2016-06-07 00:04:15

codeforces 566F. Clique in the Divisibility Graph dp

2015-09-18 11:23:53

CodeForces - 597A Divisibility （模拟）

2016-03-12 14:09:26

【CodeForces】[597A]Divisibility

2016-06-01 03:08:07

CodeForces 597A Divisibility（技巧）

2016-07-22 08:37:59

Codeforces550C:Divisibility by Eight

2015-06-09 15:50:32

[CodeForces 566F] Clique in the Divisibility Graph （记忆化搜索）

2016-04-15 17:09:01

不良信息举报

CodeForces 597A Divisibility