Number of divisors in a given range
Easy Accuracy: 56.78% Submissions: 2145 Points: 2

Given a range [m..n]. You task is to find the number of integers divisible by either a or b in the given range.

Input:
The first line of input consists of an integer T denoting the number of test cases.The next line consists of  four space seperated integers m, n, a, b where m and n denotes the range.

Output:
Print the number of integers divisible by a or b in the given range.

Constraints:
1 <= T <= 100
1 <= m,n <= 100000
1 <= a,b <= 500

Example:
Input:
2
5 11 4 6
3 1000 5 9
Output:
2
289

to report an issue on this page.

Editorial

We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?

Yes

All Submissions

My Submissions:

Login to access your submissions.