992B.md (1789B)
1 Source: https://codeforces.com/problemset/problem/992/B 2 3 B. Nastya Studies Informatics 4 5 time limit per test 6 7 1 second 8 9 memory limit per test 10 11 256 megabytes 12 13 input 14 15 standard input 16 17 output 18 19 standard output 20 21 Today on Informatics class Nastya learned about GCD and LCM (see links below). Nastya is very intelligent, so she solved all the tasks momentarily and now suggests you to solve one of them as well. 22 23 We define a pair of integers (*a*, *b*) good, if *GCD*(*a*, *b*) = *x* and *LCM*(*a*, *b*) = *y*, where *GCD*(*a*, *b*) denotes the [greatest common divisor](https://en.wikipedia.org/wiki/Greatest_common_divisor) of *a* and *b*, and *LCM*(*a*, *b*) denotes the [least common multiple](https://en.wikipedia.org/wiki/Least_common_multiple) of *a* and *b*. 24 25 You are given two integers *x* and *y*. You are to find the number of good pairs of integers (*a*, *b*) such that *l* ≤ *a*, *b* ≤ *r*. Note that pairs (*a*, *b*) and (*b*, *a*) are considered different if *a* ≠ *b*. 26 27 Input 28 29 The only line contains four integers *l*, *r*, *x*, *y* (1 ≤ *l* ≤ *r* ≤ 109, 1 ≤ *x* ≤ *y* ≤ 109). 30 31 Output 32 33 In the only line print the only integer — the answer for the problem. 34 35 Examples 36 37 Input 38 39 ``` 40 1 2 1 2 41 ``` 42 43 Output 44 45 ``` 46 2 47 ``` 48 49 Input 50 51 ``` 52 1 12 1 12 53 ``` 54 55 Output 56 57 ``` 58 4 59 ``` 60 61 Input 62 63 ``` 64 50 100 3 30 65 ``` 66 67 Output 68 69 ``` 70 0 71 ``` 72 73 Note 74 75 In the first example there are two suitable good pairs of integers (*a*, *b*): (1, 2) and (2, 1). 76 77 In the second example there are four suitable good pairs of integers (*a*, *b*): (1, 12), (12, 1), (3, 4) and (4, 3). 78 79 In the third example there are good pairs of integers, for example, (3, 30), but none of them fits the condition *l* ≤ *a*, *b* ≤ *r*.