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

Автор twoseven, история, 2 года назад, По-английски
Problem 1
Problem 2

It would be very helpful if some can share their approach to these problems. Thanks!!

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

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

Can you please share problem links ?

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

    These problems were asked in the coding round of a company some time ago. I don't have any links to these problems.

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

The first problem seems easy:

First, notice that any even whole number up to 4 * 1e18 can be expressed as the sum of two prime numbers (experimentally proven), except 2. Second , notice, that in order for their XOR to be even, they should have the same last bit in their binary represntation.

After that we notice, that all numbers except 2 and 4 that are even are expressed as sum of two odd primes, as such it means that they both have 1 in their binary representation as the last bit, which means that their XOR is even.

As such, our problem is reduced to finding pairs of indexes i, j such that a[i] * a[j] is even and not equal to either 2 or 4. After that, the problem seems easy.