给你一个序列 n,包含 n 个节点和 n−1 条边,你可以在树中选两个节点进行连无向边,要求连边后的无向图是二分图,问你能连接的最多的边数。
第一行一个整数 n(2≤n≤105),表示节点数。 接下来 n−1 行,每行两个整数 u 和 v (1≤u,v≤n),表示树中的一条边。
输出一个整数,表示能增加的最多的边数。
输入:
4
1 2
2 3
3 4
输出:
2
扫码备注加群即可,期待您的到来~
By signing up a CodeFun2000 universal account, you can submit code and join discussions in all online judging services provided by us.