TopcoderArchiveVisit Topcoder
SRM13 May 2002
SRM 88

Divisors

Problem statement, definition, constraints, and public examples.

Problem Statement

PROBLEM STATEMENT

Given an int[], return the total number of factors of every element, not
counting duplicates between elements.

k is a factor of N if k is a positive integer and there exists a positive
integer m such that k*m = N.
If N = 12, then k = 2 would be a factor since 2 * 6 = 12.
k = 5 would not be a factor since there is no positive integer m such that 5 *
m = 12.

As an example, if the int[] was {12, 24, 15}:

The factors of 12 are {1,2,3,4,6,12}
The factors of 24 are {1,2,3,4,6,8,12,24}
The factors of 15 are {1,3,5,15}

The total set of factors, not including duplicates is {1,2,3,4,5,6,8,12,15,24}
This set has 10 elements, so your method would return 10.


DEFINITION

Class: Divisors
Method: numFactors
Parameters: int[]
Returns: int
Method signature (be sure your method is public):  int numFactors(int[] numbers);

NOTES

TopCoder will ensure the validity of the inputs.  Inputs are valid if all of
the following criteria are met:
- numbers will have between 1 and 50 elements, inclusive
- each element of numbers will be between 1 and 1,000,000,000 inclusive.

EXAMPLES

(1)
numbers: {12,15,24}
your method would return: 10

(2)
numbers: {9}
your method would return: 3

(3)
numbers: {37}
your method would return: 2

(4)
numbers: {32,48}
your method would return: 11

(5)
numbers: {673873200,671846400}
your method would return: 1386

(6)
numbers:
{1996,1997,1998,1999,2000,2001,2002,2003,2004,2005,2006,2007,2008,2009,2010}
your method would return: 96

Definition

Class:
Divisors
Method:
numFactors
Parameters:
int[]
Returns:
int
Method signature:
int numFactors(int[] param0)
(be sure your method is public)

Constraints

    Examples

      No public sample cases were explicitly marked for this problem in the original data.

      Back to all problems