EllysCoprimesDiv2
SRM 577 · 2012-12-13 · by espr1t
Problem Statement
Constraints
- numbers will contain between 1 and 50 elements, inclusive.
- Each element of numbers will be between 1 and 100,000, inclusive.
- All elements of numbers will be distinct.
{2200, 42, 2184, 17}
Returns: 3
Here one possible set of additional numbers is {43, 2195, 2199}. The sorted sequence is (17, 42, 43, 2184, 2195, 2199, 2200), and as you may see, no two consecutive numbers share a divisor greater than one.
{13, 1, 6, 20, 33}
Returns: 0
For some sets, such as this one, no additional numbers are needed. When sorted, no pair of consecutive numbers shares a common divisor greater than 1.
{7, 42}
Returns: 1
Note that prime numbers are not coprime with all other numbers.
{7192, 9773, 6875, 1767, 657, 959, 9151, 6986, 8201, 8982}
Returns: 1
Small random set of numbers.
{55780, 44918, 55653, 4762, 41536, 40083, 79260, 7374, 24124, 91858, 7856,
12999, 64025, 12706, 19770, 71495, 32817, 79309, 53779, 8421, 97984, 34586,
893, 64549, 77792, 12143, 52732, 94416, 54207, 51811, 80845, 67079, 14829,
25350, 22976, 23932, 62273, 58871, 82358, 13283, 33667, 64263, 1337, 42666}
Returns: 15
Large random set of numbers.
Submissions are judged against all 107 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class EllysCoprimesDiv2 with a public method int getCount(vector<int> numbers) · 107 test cases · 2 s / 256 MB per case