menu ZJOJ
account_circle 请登录
home
首页
book
题目
apps
分类
play_circle_outline
状态
assessment
竞赛
assignment
作业
equalizer
排名
assignment_ind
登录
person_add
注册
1559: 寻找路径
时间限制:1.000s
内存限制:128MB

题目描述

 国的一个网络使用若干条线路连接若干个节点。节点间的通信是双向的。某重要数据包,为了安全起见,必须恰好被转发两次到达目的地。该包可能在任意一个节点产生,我们需要知道该网络中一共有多少种不同的转发路径。

源地址和目标地址可以相同,但中间节点必须不同。

如图 lns="http://www.w3.org/1998/Math/MathML">1 所示的网络。

lns="http://www.w3.org/1998/Math/MathML">1 \to 2 \to 3 \to 1 是允许的。

lns="http://www.w3.org/1998/Math/MathML">1 \to 2 \to 1 \to 2 或者 lns="http://www.w3.org/1998/Math/MathML">1 \to 2 \to 3 \to 2 都是非法的。

输入格式

输入数据的第一行为两个整数 lns="http://www.w3.org/1998/Math/MathML">N,M,分别表示节点个数和连接线路的条数 lns="http://www.w3.org/1998/Math/MathML">(1 \le N \le 10000,0 \le M \le 100000)

接下去有 lns="http://www.w3.org/1998/Math/MathML">M 行,每行为两个整数 lns="http://www.w3.org/1998/Math/MathML">u 和 lns="http://www.w3.org/1998/Math/MathML">v,表示节点 lns="http://www.w3.org/1998/Math/MathML">u 和 lns="http://www.w3.org/1998/Math/MathML">v 联通 lns="http://www.w3.org/1998/Math/MathML">(1 \le u,v \le N,u \neq v)

输入数据保证任意两点最多只有一条边连接,并且没有自己连自己的边,即不存在重边和自环。

输出格式

输出一个整数,表示满足要求的路径条数。


样例输入 content_copy

3 3
1 2
2 3
1 3

样例输出 content_copy

6

分类