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 xthat 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 test(s)
Input
复制代码
11 1 10
Output
复制代码
110
Input
复制代码
12 -4 4
Output
复制代码
15
AC:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#include<stdio.h> int main() { long long k,a,b; while(scanf("%lld%lld%lld",&k,&a,&b)!=EOF) { long long s=0; if(b<0) { a=-a;b=-b; long long t=a; a=b; b=t; } s=b/k-a/k; if(a%k==0||a<=0) s++; printf("%lldn",s); } return 0; }
最后
以上就是单纯便当最近收集整理的关于A. Divisibility的全部内容,更多相关A.内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复