noobcoderdsa's blog

By noobcoderdsa, 12 months ago, In English

There is an empty container. 2 types of queries are supported in this container: (i) 1 V X: Insert an element in the container with value V and power equal to X (ii) 2 V 0: Let N be the number of bits in the binary representation of V without leading zeros. Consider all the elements in the container till now, you need to count the number of elements which when divided by 2^N leaves a remainder equal to V and also find the sum of powers of such numbers. Mathematically, count the number of elements Y such that Y is present in the container and Y mod 2^N = V. For all such Y, you need to find the sum of their powers also. Given Q queries, answer queries of type 2 V 0. For time complexity, Q has an upper limit of 2*10^5.

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it