#abc265f. F - Manhattan Cafe
F - Manhattan Cafe
Score : points
问题描述
在 维空间中,两点 和 之间的曼哈顿距离 定义为:
$$\displaystyle d(x,y)=\sum_{i=1}^N \vert x_i - y_i \vert. $$若点 的各个分量 均为整数,则称该点为格点。
现在给定 维空间中的两个格点 和 。
请问有多少个格点 满足条件 且 ?请计算满足条件的格点个数对 取模的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
In an -dimensional space, the Manhattan distance between two points and is defined by:
$\displaystyle d(x,y)=\sum_{i=1}^n \vert x_i - y_i \vert.$
A point is said to be a lattice point if the components are all integers.
You are given lattice points and in an -dimensional space.
How many lattice points satisfy and ? Find the count modulo .
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
1 5
0
3
Sample Output 1
8
When , we consider points in a one-dimensional space, that is, on a number line.
lattice points satisfy the conditions: .
Sample Input 2
3 10
2 6 5
2 1 2
Sample Output 2
632
Sample Input 3
10 100
3 1 4 1 5 9 2 6 5 3
2 7 1 8 2 8 1 8 2 8
Sample Output 3
145428186
update @ 2024/3/10 11:13:00