The MEX problem
Practice
3.5 (17 votes)
Basic programming
Number theory
Problem
33% Success 1366 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code

You are given an array a of n integers. You take every subsequence of 2 lengths and the GCD of that subsequence and insert into a new array.

What is the MEX of the new array?

Note: The MEX of an array is equal to the smallest positive integer that is not present in the array. For example, MEX(1,2,4,2,3,6,7) = 5. 

Input format

  • The first line contains a single integer t denoting the number of test cases.
  • In each of the t test cases that follow contains 2 lines:
    • The first line of each test case contains a single integer n denoting the size of the array.
    • The second line contains n integers a1,a2,...,aN denoting array a

Output format

Print a single integer denoting the MEX of the new array for each test case.

Constraints

 \(1 <= t <= 20 \)

\(1 <= n <= 100000\)

\(1 <= a_{i} <= 100000\)

 

 

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
1 votes
Tags:
GCDNumber TheoryC++Math
Points:30
Tags:
MathematicsMediumOpenApprovedNumber Theory
Points:30
Tags:
MediumNumber TheoryGreatest common divisorAlgorithmsMathematicsOpenApproved