Find OR Sum of the Range

Revision en1, by neo999, 2021-02-22 15:17:48

You are given following:- - an array A consisting of N positive integers - Q queries of the form L,R,M

consider all subsequences of subarray from L to R of size M.

Determine the sum of Bitwise OR of all these subsequences. Bitwise OR of an empty subsequence is 0. If there is no Subsequence of Length M, print 0.

  • print the output with mod 998244353.
  • A subsequence is a sequence that can be derived from the given sequence by deleting 0 or more elements without changing the order of the remaining elements.
  • 1 based indexing is followed.

Example A=[1,2,3] Q=[1,3,2] // L,R,M

subarray= [1,2,3] for this we have 3 subsequences of length 2. - [1,2] [2,3] [1,3]

Bitwise OR of all above subsequences is 3+3+3=9 , so output is 9

constraints as below

Tags #bitset

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English neo999 2021-02-22 15:17:48 878 I tried using PowerSet that is Bit Set but it only works for small input.If you want i can shre my code. Plz help by telling how to approach this problem. (published)