shunfurh 于 2017.09.01 09:31 提问

Electricity

Blackouts and Dark Nights (also known as ACM++) is a company that provides electricity. The company owns several power plants, each of them supplying a small area that surrounds it. This organization brings a lot of problems - it often happens that there is not enough power in one area, while there is a large surplus in the rest of the country.

ACM++ has therefore decided to connect the networks of some of the plants together. At least in the first stage, there is no need to connect all plants to a single network, but on the other hand it may pay up to create redundant connections on critical places - i.e. the network may contain cycles. Various plans for the connections were proposed, and the complicated phase of evaluation of them has begun.

One of the criteria that has to be taken into account is the reliability of the created network. To evaluate it, we assume that the worst event that can happen is a malfunction in one of the joining points at the power plants, which might cause the network to split into several parts. While each of these parts could still work, each of them would have to cope with the problems, so it is essential to minimize the number of parts into which the network will split due to removal of one of the joining points.

Your task is to write a software that would help evaluating this risk. Your program is given a description of the network, and it should determine the maximum number of non-connected parts from that the network may consist after removal of one of the joining points (not counting the removed joining point itself).

Input

The input consists of several instances.

The first line of each instance contains two integers 1 <= P <= 10 000 and C >= 0 separated by a single space. P is the number of power plants. The power plants have assigned integers between 0 and P - 1. C is the number of connections. The following C lines of the instance describe the connections. Each of the lines contains two integers 0 <= p1, p2 < P separated by a single space, meaning that plants with numbers p1 and p2 are connected. Each connection is described exactly once and there is at most one connection between every two plants.

The instances follow each other immediately, without any separator. The input is terminated by a line containing two zeros.

Output

The output consists of several lines. The i-th line of the output corresponds to the i-th input instance. Each line of the output consists of a single integer C. C is the maximum number of the connected parts of the network that can be obtained by removing one of the joining points at power plants in the instance.

Sample Input

3 3
0 1
0 2
2 1
4 2
0 1
2 3
3 1
1 0
0 0
Sample Output

1
2
2

1个回答

caozhy      2017.09.16 23:52

Introduction to deep learning第一周测验
Introduction to deep learning 第一周测验, 10 个问题 第 1 个问题 What does the analogy “AI is the new electricity” refer to? (B) A. AI is powering personal devices in our homes and offices, similar to electr...

0.写在前面下面到了我们的神经网络与深度学习课程的作业环节了，由于在国内，所以有很多图片加载不出来，我只能臆想了。（这种简单的还好说，等到后面难的部分，我可想不出来。）1.习题1What does the analogy “AI is the new electricity” refer to?A. AI is powering personal devices in our homes and o
electricity and magnetism
1 Electricity and the Atom 13<br>2 The Nucleus 41<br>3 Circuits, Part 1 77<br>4 Circuits, Part 2 107<br>5 Fields of Force 123<br>6 Electromagnetism 143<br>A Capacitance and Inductance 169
4.electricity_and_magnetism_crowell 4.electricity_and_magnetism_crowell.pdf
4.electricity_and_magnetism_crowell.pdf4.electricity_and_magnetism_crowell.pdf4.electricity_and_magnetism_crowell.pdf
Teach Yourself Electricity & Electronics