#P9821. [ICPC 2020 Shanghai R] Sum of Log
[ICPC 2020 Shanghai R] Sum of Log
题目描述
Given two non-negative integers and , determine the value of
$$\sum_{i=0}^{X}\sum_{j=[i=0]}^{Y}[i\&j=0]\lfloor\log_2(i+j)+1\rfloor $$modulo where
- denotes bitwise AND;
- equals 1 if is true, otherwise ;
- equals the maximum integer whose value is no more than .
输入格式
The first line contains one integer denoting the number of test cases.
Each of the following lines contains two integers indicating a test case.
输出格式
For each test case, print one line containing one integer, the answer to the test case.
3
3 3
19 26
8 17
14
814
278
提示
For the first test case:
- Two pairs increase the sum by 1:
- Six pairs increase the sum by 2:
So the answer is .