InverseFactoring
SRM 425 · 2008-11-12 · by crazyb0y
SRM 425 · 2008-11-12 · by crazyb0y · Simple Math
Problem Statement
Problem Statement
A positive integer a is a proper factor of n if and only if n is a multiple of a and a does not equal 1 or n. You are given a int[] factors containing all the proper factors of some integer n. Return n.
Constraints
- factors will contain between 1 and 50 elements, inclusive.
- factors will be a valid set of proper factors of some number n, where n is between 2 and 1,000,000, inclusive.
- All elements in factors will be distinct.
Examples
0)
{2}
Returns: 4
The factors of 4 are 1, 2 and 4. Among them, only 2 is a proper factor.
1)
{2,3}
Returns: 6
2)
{4,2}
Returns: 8
The factors of 8 are 1, 2, 4, and 8. Among them, 2 and 4 are proper factors.
3)
{3}
Returns: 9
4)
{2,5}
Returns: 10
13)
{3,4,2,12,6,8}
Returns: 24
The proper factors of 24 are 2, 3, 4, 6, 8 and 12.
Submissions are judged against all 176 archived test cases, of which 6 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class InverseFactoring with a public method int getTheNumber(vector<int> factors) · 176 test cases · 2 s / 256 MB per case