#P15737. [JAG 2024 Summer Camp #2] I Love Square Number
[JAG 2024 Summer Camp #2] I Love Square Number
题目描述
Consider a graph with vertices and edges, where is an integer greater than or equals to .
- The set of vertices is .
- There is an edge with weight between and (for and ).
- There is an edge with weight between and (for and ).
- There is an edge with weight between and (for and ).
For a simple path in this graph, the weight of the path is defined as the product of the weights of the edges that the path traverses.
Determine the number of unordered pairs of distinct vertices such that any simple path from to has a weight that is a square number.
输入格式
The input is given in the following format:
$$\begin{aligned} &N \\ &a_{1,1} \\ &a_{2,1} \ a_{2,2} \\ &\vdots \\ &a_{N-1,1} \ \cdots \ a_{N-1,N-1} \\ &b_{1,1} \\ &b_{2,1} \ b_{2,2} \\ &\vdots \\ &b_{N-1,1} \ \cdots \ b_{N-1,N-1} \\ &c_{2,1} \\ &c_{3,1} \ c_{3,2} \\ &\vdots \\ &c_{N,1} \ \cdots \ c_{N,N-1} \end{aligned} $$- All input values are integers.
输出格式
Output the answer.
2
1
2
2
1
3
1
2 3
4
5 6
7
8 9
0