Topic Links:
GCD
Time limit:6000/3000 MS (java/others)
Memory limit:32768/32768 K (java/others)
problem DescriptionGiven 5 integers:a, B, C, D, K, you ' re-find x in a...b, y in C...d, GCD (x, y) = K. GCD (x, y) means the greatest co Mmon divisor of x and Y. Since the number of choices may is very large, you ' re only required to output the total number of different number pairs.
Notice that, (x=5, y=7) and (x=7, y=5) is considered to be the same.
Yoiu can assume a = c = 1 in the all test cases.
InputThe input consists of several test cases. The first line of the input is the number of the cases. There is no more than 3,000 cases.
Each case contains five integers:a, B, C, D, K, 0 < a <= b <= 100,000, 0 < c <= D <= 100,000, 0 <= K <= 100,000, as described above.
OutputFor each test case, print the number of choices. Use the format in the example.
Sample Input 21 3 1 5 11 11014 1 14409 9
Sample Output Case 1:9case 2:736,427
Test Instructions:for gcd (x, y) ==k (x, y) logarithm;1<=x<=b,1<=y<=d;
Ideas:gcd (x, y) =k, i.e. gcd (x/k,y/k) =1;becomes the logarithm of the coprime in [1,b/k][1,d/k];F (d) indicates the logarithm of the gcd (x, y) =d; F (d) indicates the logarithm of D|GCD (x, y);F (1) is asked here, and the Möbius inversion F (n) =∑ (n|d) Μ (d/n) F (d) is knownf (1) =∑µ (i) *f (i) (1<=i<=min (b/k,d/k));
AC Code:
hdu-1695 GCD (Möbius inversion)