luogu#P5177. 签到
签到
Background
Solution: https://blog.csdn.net/kkkksc03/article/details/85008142
Problem Description
Compute $\sum_{i=1}^n \sum_{j=1}^n i \ xor \ j \in [\min(i,j),\max(i,j)]$.
Since the answer may be very large, output the value modulo .
Input Format
The first line contains an integer , the number of test cases.
The next lines each contain one integer .
Output Format
For each test case, output the answer.
3
10
100
1000
20
2634
325502
Hint
Explanation for the first sample:
There are pairs that satisfy the condition.
i=1 j=3 i^j=2
i=1 j=5 i^j=4
i=1 j=7 i^j=6
i=1 j=9 i^j=8
i=2 j=6 i^j=4
i=2 j=7 i^j=5
i=2 j=10 i^j=8
i=3 j=1 i^j=2
i=3 j=6 i^j=5
i=3 j=7 i^j=4
i=3 j=10 i^j=9
i=5 j=1 i^j=4
i=6 j=2 i^j=4
i=6 j=3 i^j=5
i=7 j=1 i^j=6
i=7 j=2 i^j=5
i=7 j=3 i^j=4
i=9 j=1 i^j=8
i=10 j=2 i^j=8
i=10 j=3 i^j=9
Constraints:
For of the testdata, , .
For of the testdata, , .
For of the testdata, , .
For the last test point, .
Translated by ChatGPT 5