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

Автор xoringbitset, 3 года назад, По-английски

Hello, there, I recently came up with a task and while solving it, thought the idea was elegant so just wanted to share it here, so people could enjoy it and I hopefully could see more ideas to solve it!

The task goes like this-

Given an array of integers, output distinct indices of two numbers, it they exist, such that bitwise & of both the numbers is greater than or equal to the GCD(Greatest common divisor) of both the numbers.

$$$2<=n<=10^{5}$$$

$$$1<=a_{i}<=10^{9}$$$

Hints-

Hint 1
Hint 2
Hint 3
Hint 4

I will write a solution in a while, but I think the hints must have been enough for you to solve this problem ;). Let me know if there are any other solutions which work, and your thoughts about whether you enjoyed this problem or not.

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

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