Пожалуйста, прочтите новое правило об ограничении использования AI-инструментов. ×

Блог пользователя Bibhu_295

Автор Bibhu_295, история, 6 лет назад, По-английски

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

Полный текст и комментарии »

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится