Problem Description
Loading...
Problem Analysis
Force it into a one-liner AC
First, we know
there are n/k numbers divisible by k in 0~n
so when the whole interval is greater than 0
we have b/k-(a-1)/k
similarly, when the whole interval is less than 0
a/k-(b+1)/k
when the interval crosses 0
then add 1 on top of a/k+b/k (0/k is also divisible)
Also note the case where a/k<0 or b/k<0
so just add an absolute value.
Finally, the data range is relatively large
so __int64 can be used.
Use algorithm as the header for abs
because abs in math.h seems to be of int type.
ccpp
| |
Problem link: 【CodeForces】[597A]Divisibility