[JRKSJ R6] Nothing

Luogu
IDLGP8567
Time1000ms
Memory128MB
DifficultyP1
数学2022洛谷原创
我们定义 $f(x)$ 表示 $x$ 在 $2$ 进制下最低的 $1$ 的位置(你需要注意,二进制下的最低位是第 $0 $ 位)。以下是其在 `C++` 语言中的代码(未考虑数据类型造成的问题): ```c++ int f(int x){ int ans = 0; while (x % 2 == 0){ x /= 2; ans += 1; } return ans; } ``` 共有 $T$ 组询问,每组询问给定区间 $[l,r]$,求有多少个 $i\in [l,r]$ 使得 $f(i)< f(i+1)$。 ## Input 第一行一个正整数 $T$。\ 接下来 $T$ 行每行两个正整数 $l,r$ 表示一次询问。 ## Output $T$ 行每行一个整数表示答案。 [samples] ## Background 【此处应有图】 ## Note ### 数据规模 本题采用捆绑测试。 | $\text{Subtask}$ | $T\le$ | 特殊限制 | $\text{Score}$ | | :----------: | :----------: | :----------: | :----------: | | $1$ | $10^5$ | $l=r$ | $10$ | | $2$ | $10^4$ | $r-l\le10^3$ | $30$ | | $3$ | $10^5$ | $r\le10^6$ | $20$ | | $4$ | $10^5$ | 无 | $40$ | 对于 $100\%$ 的数据,$1\le T\le 10^5$,$1\le l\le r\le 10^{18}$。
Samples
Input #1
2
3 5
15 20
Output #1
2
3
API Response (JSON)
{
  "problem": {
    "name": "[JRKSJ R6] Nothing",
    "description": {
      "content": "我们定义 $f(x)$ 表示 $x$ 在 $2$ 进制下最低的 $1$ 的位置(你需要注意,二进制下的最低位是第 $0 $ 位)。以下是其在 `C++` 语言中的代码(未考虑数据类型造成的问题): ```c++ int f(int x){ \tint ans = 0; \twhile (x % 2 == 0){ \t\tx /= 2; \t\tans += 1; \t} \treturn ans; } ``` ",
      "description_type": "Markdown"
    },
    "platform": "Luogu",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 131072
    },
    "difficulty": {
      "LuoguStyle": "P1"
    },
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "LGP8567"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "我们定义 $f(x)$ 表示 $x$ 在 $2$ 进制下最低的 $1$ 的位置(你需要注意,二进制下的最低位是第 $0 $ 位)。以下是其在 `C++` 语言中的代码(未考虑数据类型造成的问题):\n\n```c++\nint f(int x){\n\tint ans = 0;\n\twhile (x % 2 == 0){\n\t\tx /= 2;\n\t\tans += 1;\n\t}\n\treturn ans;\n}\n```\n...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments