Connection Status:
Competition Arena > LeastMajorityMultiple
SRM 434 · 2009-02-07 · by darnley · Search, Simple Math
Class Name: LeastMajorityMultiple
Return Type: int
Method Name: leastMajorityMultiple
Arg Types: (int, int, int, int, int)
Problem Statement

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.

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)
7
8
4
6
5
Returns: 24

Note that the given numbers might be equal. 20 is divisible by 4, 4, and 5 - the majority of the given five numbers.

2)
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.

3)
30
45
23
26
56
Returns: 1170
4)
3
14
15
92
65
Returns: 195

Submissions are judged against all 108 archived test cases, of which 5 are shown here. Case numbers match the judge’s.

Coding Area

Language: C++17 · define a public class LeastMajorityMultiple with a public method int leastMajorityMultiple(int a, int b, int c, int d, int e) · 108 test cases · 2 s / 256 MB per case

Submitting as anonymous