confusedcoder's blog

By confusedcoder, history, 8 years ago, In English

We have an array, Let's call it A, with upto 5*10^5 elements and each element <=10^6, and Q-the number of queries. Q<=5*10^5.
In ith query- 1<=i<=Q , we need to find the prime factor- let's call it X- of "i" which has the maximum power in the prime factorization of "i".
if X is odd, we divide the least element of the array by 2, and if X is even, we multiply the maximum element of the array by 2. If an element becomes 0, we remove it from the array.
We can't change the order of elements of the array.
We need to find the array after all the Q queries.

How to implement it?
Thanks in advance :)

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it