-->
当前位置:首页 > 题库

PROGRAMMING:Xiao Chen's social network

Luz5年前 (2021-05-10)题库390
Xiao Chen is summarizing his circle of friends recently. Through certain methods, he knows that a certain two people are friends. In order to simplify the statistics, it is assumed that a friend's friend is his own friend, so a friend's friend and he are also friends. Now Xiao Chen is very upset. He wants to make friends with all the people. But it takes a certain amount of energy to make a friend. He doesn't want to be too tired. Now he numbers each friend (Xiao Chen is not included), and gives you the information of these friend relationships. He wants to know that he needs to make at least a few more friends to achieve a friend relationship with everyone.
###Input format:
In the first line, N, m, n is the largest number of these information, and M is the number of known friend relationship information( 1<=n<=1e6,1<=m<=1e6)
Next, 2 to N + 1 rows, two data a and B for each row. Represents that a and B are friends (1 < = a, B < = n)
Ensure that all data are integers.
###Output format:
One line, one number, represents that Xiao Chen needs to make at least a few more friends.
###Input example:
```in
4 2
1 2
2 3
```
###Output example:
```out
two
```
Example explanation: it is obvious that there are two groups of friends {1,2,3}, {4}. Xiao Chen only needs to make friends with one of the two groups to achieve his goal.







answer:If there is no answer, please comment