xoringbitset's blog

By xoringbitset, 3 years ago, In English

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.

Full text and comments »

  • Vote: I like it
  • +328
  • Vote: I do not like it