Please read the new rule regarding the restriction on the use of AI tools. ×

Mahmoud and Ehab and another array construction task

Revision en1, by Bibhu_295, 2018-04-07 07:38:24

Mahmoud and Ehab and another array construction task We have to make an array b such that all elements in will be coprime.

What we need to consider: First, think of how can you find the prime factors of all number present in the array in an efficient way. Prime Factorization in log(n)

Then we keep making all the prime factors of the array of as visited and if a prime factor repeats we stop and choose an element greedily and then from next place we keep feeling starting from the minimum number whose all factors are not at all visited. Source Code

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en2 English Bibhu_295 2018-04-07 07:39:04 3 Tiny change: 'ements in will be c' -> 'ements in it will be c'
en1 English Bibhu_295 2018-04-07 07:38:24 809 Initial revision (published)