当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3763:Tour in Wonder Land

题目描述

You must have heard of the literature "Alice's Adventures in Wonderland"! The 3D film "Alice in Wonderland" published by Disney Company becomes the most popular film in 2010! Today, Alice starts her new adventure in Wonderland again!

In Wonderland, there are n cities, numbered from 1 to n. The capital is city 1. Cities are connected by bi-directional roads. The road system is constructed so that from every city, there is exactly one way to reach any other.

Alice hopes that she could make a tour in which she visits each city exactly once then return to the capital. Furthermore, she doesn't want to traverse any road more than once. Obviously, it is impossible to make such tour with current road system.

However, in Wonderland, we can use magic spells! The Cheshire Cat, with his magic power, plans to construct more roads to make Alice's dream come true. Sadly, if he used too many magic spells, he would be weaken. "What is the minimum number of roads I have to construct?" - The poor cat wonders. Could you help him answer this question?

输入解释

The first line of input contains the number n --- the number of cities in Wonderland (3 ≤ n ≤ 100 000). The following n-1 lines describe the roads. Each road is represented by two integers --- the indexes of two cities it connects.

输出解释

The minimum number of roads to construct.

输入样例
5
1 2
2 3
2 4
1 5
输出样例
2
提示

In this example, we can construct 2 roads: 3-4 and 4-5, then Alice will be able to take a tour 1-2-3-4-5-1


该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3763

最后修改于 2020-10-29T07:10:49+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536