TopCoder problem "FactoVisors" used in SRM 406 (Division II Level Two)



Problem Statement

    Return the number of positive integers that are multiples of each number in divisors and divisors of each number in multiples.
 

Definition

    
Class:FactoVisors
Method:getNum
Parameters:int[], int[]
Returns:int
Method signature:int getNum(int[] divisors, int[] multiples)
(be sure your method is public)
    
 

Constraints

-divisors and multiples will each contain between 1 and 50 elements, inclusive.
-Each element of divisors and multiples will be between 1 and 10^9, inclusive.
 

Examples

0)
    
{1}
{100}
Returns: 9
The working integers are 1, 2, 4, 5, 10, 20, 25, 50, and 100.
1)
    
{6,9}
{18}
Returns: 1
18 is the only integer that works.
2)
    
{6,9}
{96,180}
Returns: 0
No integers work.
3)
    
{2,4}
{256}
Returns: 7
4)
    
{1000,10000,100000}
{1000000000}
Returns: 25
Beware of overflow.

Problem url:

http://www.topcoder.com/stat?c=problem_statement&pm=8427

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=12178&pm=8427

Writer:

eleusive

Testers:

PabloGilberto , Olexiy , gawry , ivan_metelsky

Problem categories:

Math