#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
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.
题目大意
给定两个非负整数 ,计算下列式子对 取模的值:
其中:
- 表示按位与。
- 等于 ,当且仅当表达式 为真;否则 等于 。
- 表示不大于 的最大整数。
提示
For the first test case:
- Two pairs increase the sum by 1:
- Six pairs increase the sum by 2:
So the answer is .