#abc269f. F - Numbered Checker
F - Numbered Checker
Score : points
问题描述
我们有一个 行和 列的网格。在从上到下第 行、从左到右第 列的格子 上写有一个整数 。
现在,我们对这个网格执行以下操作:
- 对于每一個满足 是奇数的格子 ,将该格子上的整数替换为 。
完成操作后,解答关于此网格的 个问题。第 个问题如下:
- 求满足以下所有条件的格子 上所写整数之和,取模 。
- 。
- 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have a grid with rows and columns. The square at the -th row from the top and -th column from the left has an integer written on it.
Let us perform the following operation on this grid.
- For every square such that is odd, replace the integer on that square with .
Answer questions on the grid after the operation.
The -th question is as follows:
- Find the sum of the integers written on all squares that satisfy all of the following conditions, modulo .
- .
- .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain the answer to the -th question as an integer.
Sample Input 1
5 4
6
1 3 2 4
1 5 1 1
5 5 1 4
4 4 2 2
5 5 4 4
1 5 1 4
Sample Output 1
28
27
36
14
0
104
The grid in this input is shown below.
This input contains six questions.
- The answer to the first question is .
- The answer to the second question is .
- The answer to the third question is .
- The answer to the fourth question is .
- The answer to the fifth question is .
- The answer to the sixth question is .
Sample Input 2
1000000000 1000000000
3
1000000000 1000000000 1000000000 1000000000
165997482 306594988 719483261 992306147
1 1000000000 1 1000000000
Sample Output 2
716070898
240994972
536839100
For the first question, note that although the integer written on the square is , you are to find it modulo .
Sample Input 3
999999999 999999999
3
999999999 999999999 999999999 999999999
216499784 840031647 84657913 415448790
1 999999999 1 999999999
Sample Output 3
712559605
648737448
540261130
update @ 2024/3/10 11:21:57