codeforces-597【思维】

来源:互联网 发布:网络推广托管 编辑:程序博客网 时间:2024/05/16 11:43

题目链接:点击打开链接

A. Divisibility
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

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.

Examples
input
1 1 10
output
10
input
2 -4 4
output
5
#include<cstdio>#include<algorithm>#include<cstring>#define LL long longusing namespace std;LL k,a,b;int main(){while(~scanf("%I64d %I64d %I64d",&k,&a,&b)){LL ans=0;LL cnt1=abs(a)/k;LL cnt2=abs(b)/k;if(a>=0){ans=cnt2-cnt1;if(a%k==0)ans++;}else if(b<=0){ans=cnt1-cnt2;if(b%k==0)ans++;}else{ans=cnt1+cnt2+1;}printf("%I64d\n",ans);}return 0;}


0 0