QOJ.ac

QOJ

Limite de temps : 2 s Limite de mémoire : 512 MB Points totaux : 100

#14177. r2pspc

Statistiques

Given a sequence $a_1, \dots, a_n$, there are $m$ queries. Each query asks for the number of $1$s in the binary representation of $\sum\limits_{i=l}^r 2^{a_i}$.

Input

The first line contains two integers $n$ and $m$.

The second line contains $n$ integers $a_1, \dots, a_n$.

The next $m$ lines each contain $l$ and $r$, representing a query.

Output

Output $m$ lines, each containing the answer to the corresponding query.

Examples

Input 1

5 2
2 3 1 2 32
2 5
2 5

Output 1

4
4

Subtasks

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

For $100\%$ of the data, $1\le n\le {10}^5$, $1\le m\le {10}^6$, $1\le a_i\le 10^9$, $1\le l\le r\le n$.

For $25\%$ of the data, $n, m\le 1000$.

For another $25\%$ of the data, $a_i\le 100$.

For another $25\%$ of the data, $m\le 10^5$.

For the remaining $25\%$ of the data, there are no special restrictions.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.