#P13769. [CERC 2021] Lines in a grid
[CERC 2021] Lines in a grid
题目描述
Suppose that we are given a integer grid, e.g. . Let be the number of different lines that intersect with at least two points on the grid.
For , there are exactly 20 such lines, as drawn on the image below.
:::align{center}
:::
Compute for all given .
输入格式
First line contains an integer – the number of queries. The second line contains space-separated integers .
输出格式
Print numbers , each in its own line. Since can be large, print them modulo .
3
1 3 2
0
20
6