Infosys Exam

Revision en1, by Utsav1998, 2022-07-30 11:19:28

Please provide the approach of the following ,I have tried but i didn't came up with a good approach

You are given an array A of length N and an integer K. It is given that a number m is called special if gcd(m,Aj) = 1 for all 0<=j<N

Let R be an array containing all special number in the range [ 1 , K ] inclusive in sorted order . Your task is to return R.

Note : A follows 0-based indexing.

Input Format The first line contains an integer N , denoting the number of elements in A. The next line contains an integer K , denoting the given integer. Each line i of the N subsequent lines (where 0<=i<N) contains an integer describing A[i].

Constraints 1<=N<=10^5 1<=K<=10^5 1<=A[i]<=10^5

Sample Input Sample Output 3 1 5 5 1 2 3

4 1 5 2 3 4 3 5 7

4 1 1 1 1 1 1

Tags #dsa, #sde

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English Utsav1998 2022-07-30 11:19:28 819 Initial revision (published)