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

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

How to solve this problem?

Problem:

You are given an array of N integers. Now, you can choose any strictly increasing subsequence of the array and calculate the bitwise OR of all the elements of the subsequence. A subsequence can be obtained by deleting several elements (possibly none or all) from the array without changing the order of the remaining elements. A sequence a1, a2, a3…am is called strictly increasing if a1 < a2 < a3 <…< am

Task:

Determine all possible different values of p (p>=0) such that there exist a strictly increasing subsequence such that the bitwise OR of all the elements of the subsequence is equal to p.

Constraints:

1 <= N <= 10^4
1 ≤ arr[i] < 1024

Sample Input:

1
4
3 5 1 5

Sample Output:

0 1 3 5 7

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

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