#ABC133B. Good Distance
Good Distance
题目描述
There are points in a -dimensional space.
The coordinates of the -th point are .
The distance between two points with coordinates and is $\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}$.
How many pairs are there such that the distance between the -th point and the -th point is an integer?
在一个 \ 维空间中有 个点。
第 个点的坐标是 。
坐标为 和 的两点之间的距离为 $\sqrt{(y_1 - z_1)^2 + (y_2 - z_2)^2 + ... + (y_D - z_D)^2}$ 。
和 有多少对? ,使得 /th 点与 /th 点之间的距离是整数?
输入格式
$N$ $D$
$X_{11}$ $X_{12}$ $...$ $X_{1D}$
$X_{21}$ $X_{22}$ $...$ $X_{2D}$
$\vdots$
$X_{N1}$ $X_{N2}$ $...$ $X_{ND}$
输出格式
打印 中 (第 1 个点)与 (第 1 个点)之间的距离为整数的线对数。 ,使得 /th 点与 /th 点之间的距离为整数。
样例 #1
样例输入 #1
3 2
1 2
5 5
-2 8
样例输出 #1
1
样例 #2
样例输入 #2
3 4
-3 7 8 2
-12 1 10 2
-2 8 9 3
样例输出 #2
2
样例 #3
样例输入 #3
5 1
1
2
3
4
5
样例输出 #3
10
说明
数据规模与约定
- 所有输入值均为整数。
- 没有两个给定点的坐标是相同的。也就是说,如果 ,则存在 这样的 。
样例 解释
距离为整数的配对数为 1,如下所示:
- 第一点与第二点的距离为 ,是整数。
- 第二点与第三点的距离为 ,不是整数。
- 第三点与第一点之间的距离为 ,不是整数。