#P6860. 象棋与马
象棋与马
Description
Amazing John has an infinite chessboard to play Knight Chess.
There is a knight starting at . Each move can be an rectangle (that is, it can go from to or ).
If the knight can reach any point on the board using the moves above, then ; otherwise .
Now Amazing John gives you queries. In each query, he gives a positive integer , and he wants to know the value of
$$\left ( \sum_{a=1}^n\sum_{b=1}^np(a,b) \right )\bmod\ 2^{64}$$Input Format
This problem contains multiple test cases.
The first line contains an integer , the number of test cases.
The next lines each contain an integer , representing one query.
Output Format
Output lines in total.
For each query, output one integer, namely the value of
$$\left ( \sum_{a=1}^n\sum_{b=1}^np(a,b) \right )\bmod\ 2^{64}$$3
2
3
4
2
4
8
Hint
Sample explanation: when , the cases with value are .
This problem enables Subtasks.
| Subtask | Test Points | Constraints | Score |
|---|---|---|---|
Note 1: For test points with , the time limit is 4 s; for all other test points, it is 2.5 s. For all test points, the memory limit is 500 MB.
Note 2: Outputting the answer means using natural overflow of 64-bit unsigned integers.
This problem enables the -O2 optimization switch.
Translated by ChatGPT 5
京公网安备 11011102002149号