#P9986. [Ynoi2079] r2pspc

[Ynoi2079] r2pspc

Problem Description

Given a sequence a1,…,ana_1,\dots,a_n and mm queries, each query asks for the number of 11 bits in the binary representation of ∑i=lr2ai\sum\limits_{i=l}^r 2^{a_i}.

Input Format

The first line contains two integers n,mn, m.

The second line contains nn integers a1,…,ana_1,\dots,a_n.

The next mm lines each contain l,rl, r, representing one query.

Output Format

Output mm lines. Each line is the answer to the corresponding query.

5 2
2 3 1 2 32
2 5
2 5
4
4

Hint

Idea: rushcheyo, Solution: djq_cpp&ccz181078, Code: ccz181078, Data: ccz181078.

Constraints: For 100%100\% of the testdata, 1≤n≤1051\le n\le {10}^5, 1≤m≤1061\le m\le {10}^6, 1≤ai≤1091\le a_i\le 10^9, 1≤l≤r≤n1\le l\le r\le n.

For 25%25\% of the testdata, n,m≤1000n, m\le 1000.

For another 25%25\% of the testdata, ai≤100a_i\le 100.

For another 25%25\% of the testdata, m≤105m\le 10^5.

For the remaining 25%25\% of the testdata, there are no special constraints.

Translated by ChatGPT 5