logo AlgoBeat OnlineJudge
登录 注册

#215417. [MCO 2025] Long Binary String

内存限制:256 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

A long binary string is formed via the following process:

  1. Start with the string .

  2. Every second, we replace each of the current string with and each of the current string with .

The state of the string in the first few seconds is as follows: .

Let be the string obtained at the end of the process after running it for seconds. You want to answer queries of the following type: how many ones are there between the -th character and -th character (inclusive) of ?

输入格式

The first line contains a single integer (), denoting the number of queries.

The next lines each contain two space-separated integers (), representing the queries.

输出格式

For each query, output the number of ones between the -th character and -th character (inclusive) of .

样例

样例输入 1

3
3 9
6 6
1 12

样例输出 1

5
1
8

数据范围与提示

Note

One can show that the first characters of the string are .

For the first query, there are ones between the 3rd character and 9th character. The relevant substring is .

For the second query, there is one between the 6th character and 6th character. The relevant substring is .

For the third query, there are ones between the 1st character and 12th character. The relevant substring is .

Scoring

Subtask ( points): ,

Subtask ( points): ,

Subtask ( points):

Subtask ( points): , is equal to the length of the string after some integer number of seconds.

Subtask ( points):

Subtask ( points):

Subtask ( points):

Subtask ( points): No additional constraints