TopcoderArchive
SRM18 Jun 2008
SRM 406

FactoVisors

Problem statement, definition, constraints, and public examples.

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

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