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

Bibhu_295's blog

By Bibhu_295, history, 6 years ago, In English

Mahmoud and Ehab and another array construction task We have to make an array b such that all elements in it 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

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it