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

Автор i_am_not_special, история, 5 часов назад, По-английски

So the question is count the number of increasing subsequence such that the gcd of subsequence will be equal to 1.

1 <= size of array <= 1e5 1 <= a[i] <= 1e6

can anyone help me solve this problem.

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

»
5 часов назад, # |
  Проголосовать: нравится +2 Проголосовать: не нравится

0(n) = 0 * n = 0, wtf??

  • »
    »
    5 часов назад, # ^ |
      Проголосовать: нравится 0 Проголосовать: не нравится

    ?

    • »
      »
      »
      5 часов назад, # ^ |
        Проголосовать: нравится +2 Проголосовать: не нравится

      ???

      u got me, you've just fixed that

      • »
        »
        »
        »
        4 часа назад, # ^ |
          Проголосовать: нравится 0 Проголосовать: не нравится

        do you have any solution for this problem?

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by i_am_not_special (previous revision, new revision, compare).

»
5 часов назад, # |
  Проголосовать: нравится 0 Проголосовать: не нравится

Auto comment: topic has been updated by i_am_not_special (previous revision, new revision, compare).

»
3 часа назад, # |
  Проголосовать: нравится +1 Проголосовать: не нравится

Create a another array called primes which will have all the prime numbers in the given array in the same seqvence of the array and now create an another array called ream where ream[i] is how many numbers which are greater than primes[i] and right side of primes[i]. Now answer is sum of 2**k for each k in ream (pardon me if it's wrong).
For finding primes we can use Sieve of Eratosthenes.
For building ream array we can use merge sort (or) fenwick tree.