logo AlgoBeat OnlineJudge
登录 注册

#215794. [JAG 2024 Summer Camp #2] I Love Square Number

内存限制:1024 MiB 时间限制:2000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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:

  • All input values are integers.

输出格式

Output the answer.

样例

样例输入 1

2
1
2
2

样例输出 1

1

样例输入 2

3
1
2 3
4
5 6
7
8 9

样例输出 2

0