luogu#P9821. [ICPC2020 Shanghai R] Sum of Log
[ICPC2020 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.
题目大意
给定两个非负整数 ,计算下列式子对 取模的值:
$$\sum\limits_{i=0}^{X}{\sum\limits_{j=[i=0]}^{Y}{[i \& j=0]\lfloor \log_2(i+j)+1\rfloor}} $$其中:
- 表示按位与。
- 等于 ,当且仅当表达式 为真;否则 等于 。
- 表示不大于 的最大整数。
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 .