TopCoder problem "LeastMajorityMultiple" used in SRM 434 (Division II Level One)



Problem Statement

    

Given five positive integers, their least majority multiple is the smallest positive integer that is divisible by at least three of them.

Given distinct ints a, b, c, d and e, return their least majority multiple.

 

Definition

    
Class:LeastMajorityMultiple
Method:leastMajorityMultiple
Parameters:int, int, int, int, int
Returns:int
Method signature:int leastMajorityMultiple(int a, int b, int c, int d, int e)
(be sure your method is public)
    
 

Constraints

-a, b, c, d and e will each be between 1 and 100, inclusive.
-a, b, c, d and e will be distinct.
 

Examples

0)
    
1
2
3
4
5
Returns: 4
4 is divisible by 1, 2, and 4 - the majority of the given five numbers.
1)
    
30
42
70
35
90
Returns: 210
210 is divisible by 30, 42, 70, and 35 - four out of five numbers, which is a majority.
2)
    
30
45
23
26
56
Returns: 1170
3)
    
3
14
15
92
65
Returns: 195

Problem url:

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

Problem stats url:

http://www.topcoder.com/tc?module=ProblemDetail&rd=13696&pm=10267

Writer:

darnley

Testers:

PabloGilberto , Olexiy , ivan_metelsky

Problem categories:

Search, Simple Math