LeastMajorityMultiple
SRM 434 · 2009-02-07 · by darnley
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
Constraints
- a, b, c, d and e will each be between 1 and 100, inclusive.
- a, b, c, d and e will be distinct.
1 2 3 4 5 Returns: 4
4 is divisible by 1, 2, and 4 - the majority of the given five numbers.
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.
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.
30 45 23 26 56 Returns: 1170
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.
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