PROBLEM STATEMENT
You are given the task of finding the total number of integers between 1 and N,
inclusive, that are divisible by one or more integers from a list. As an
example, consider the following case: N=20, div={2,11}. The numbers between 1
and 20 divisible by 2 or 11 are {2,4,6,8,10,11,12,14,16,18,20}, so the method
would return 11, which is the total number of integers between 1 and 20
divisible by 2 or 11.
Create a class QuickDiv that contains the method numDivisible, which takes a
number representing N and a list of integers representing div. The method
should calculate and return the total number of integers between 1 and N,
inclusive, which are divisible by one or more integers in div.
DEFINITION
Class: QuickDiv
Method: numDivisible
Parameters: int, int[]
Returns: int
Method signature (be sure your method is public): int numDivisible(int N, int[]
div);
NOTES
-A number x is divisible by y if x mod y=0
-A number x is divisible by y if y*c=x (c being some integer)
-Elements in div may be repeated, and may appear in any order.
-If some integer between 1 and N is divisible by more than one element in div,
it still counts only once towards the final result.
TopCoder will ensure the validity of the inputs. Inputs are valid if all of
the following criteria are met:
-N is between 1 and 1000000000, inclusive.
-div contains between 1 and 15 elements, inclusive.
-Each element in div is between 1 and 1000000000, inclusive.
EXAMPLES
Example 1: N=20, div={11,2}
The resulting set of numbers between 1 and 20, and divisible by 11 or 2 is
{2,4,6,8,10,11,12,14,16,18,20}.
The method returns the number of elements in the resulting set, which is 11.
Example 2: N=50, div={2,3,10}. The method returns 33.
Example 3: N=50, div={2,3,10,3}. The element 3 is repeated twice, but the
result is still the same. The method returns 33.
Example 4: N=1000, div={2,4}. The method returns 500.
Example 5: N=1000000, div={2,3,5}. The method returns 733334.
Example 6: N=1000000, div={2,8,611,547,890,1000,1001}. The method returns
502219.