CommonMultiples
SRM 346 · 2007-04-24 · by soul-net
SRM 346 · 2007-04-24 · by soul-net · Simple Math
Problem Statement
Problem Statement
You will be given a
Constraints
- a will contain between 1 and 50 elements, inclusive.
- Each element of a will be between 1 and 100, inclusive.
- upper will be between 1 and 2000000000 (2*109), inclusive.
- lower will be between 1 and upper, inclusive.
Examples
0)
{1,2,3}
5
15
Returns: 2
The only numbers between 5 and 15 that are multiples of 1, 2 and 3 are 6 and 12.
1)
{1,2,4,8,16,32,64}
128
128
Returns: 1
128 is a multiple of all smaller powers of 2.
2)
{2,3,5,7,11,13,17,19,23,29,31,37,41,43,49}
1
2000000000
Returns: 0
3)
{1,1,1}
1
2000000000
Returns: 2000000000
4)
{4}
1
2000000000
Returns: 500000000
Submissions are judged against all 192 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Coding Area
Language: C++17 · define a public class CommonMultiples with a public method int countCommMult(vector<int> a, int lower, int upper) · 192 test cases · 2 s / 256 MB per case