#abc280g. G - Do Use Hexagon Grid 2
G - Do Use Hexagon Grid 2
Score : points
问题描述
我们有一个无限的六边形网格,如下图所示。
一个六边形格子用两个整数 和 表示为 。
格子 与以下六个格子相邻:
让我们定义两个格子 和 之间的距离为从格子 移动到格子 所需的最小步数,每次移动只能移到相邻的格子上。
例如,格子 和 之间的距离是 ,而格子 和 之间的距离是 。
给你 个格子 。
在这些 个格子中选择一个或多个格子,要求任意两个被选中的格子之间的距离至多为 ,有多少种不同的选择方法?
请计算满足条件的选择方法数量对 取模的结果。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
We have an infinite hexagonal grid shown below.
A hexagonal cell is represented as with two integers and .
Cell is adjacent to the following six cells:
Let us define the distance between two cells and by the minimum number of moves required to travel from cell to cell by repeatedly moving to an adjacent cell.
For example, the distance between cells and is , and the distance between cells and is .
You are given cells .
How many ways are there to choose one or more from these cells so that the distance between any two of the chosen cells is at most ?
Find the count modulo .
Constraints
- are pairwise distinct.
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
3 1
0 0
0 1
1 0
Sample Output 1
5
There are five possible sets of the chosen cells: , and .
Sample Input 2
9 1
0 0
0 1
0 2
1 0
1 1
1 2
2 0
2 1
2 2
Sample Output 2
33
Sample Input 3
5 10000000000
314159265 358979323
846264338 -327950288
-419716939 937510582
-97494459 -230781640
628620899 862803482
Sample Output 3
31
update @ 2024/3/10 11:47:03