Techno is a large island country with exactly 101 cities. The country is extremely advanced when it comes to technology, and, as a result, they have assigned a quantum supercomputer in order to manage all of the construction and management in the country.
The supercomputer, though, encountered a glitch. One day, when it was asked to connect all of the cities in the country using roads, it encountered an error which caused it to build a road between a random pair of cities, only stopping when all of the cities have been connected. In the worst case scenario, how many roads will the country have to build such that any two cities are connected?
Note : If you can find a path from city A to city B (possibly passing through other cities) then city A and city B are connected.
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
The maximum number of roads is achieved when 1 0 0 cities are connected in such a way that any two cities are connected by a road, then the 1 0 1 st city is connected to any of the 1 0 0 cities, resulting in ( 2 1 0 0 ) + 1 = 4 9 5 1 roads.
We then prove that 4 9 5 1 roads will always connect all of the cities. Assume that there are two groups of connected cities which are not connected to each other. Let the first group have x cities. The second group will then have 1 0 1 − x cities. The first group has at most ( 2 x ) = 2 ( x ) ( x − 1 ) roads. Similarly, the second group has at most ( 2 1 0 1 − x ) = 2 ( 1 0 1 − x ) ( 1 0 0 − x ) roads. All in all, the two groups will have 2 ( x ) ( x − 1 ) + 2 ( 1 0 1 − x ) ( 1 0 0 − x ) = x 2 − 1 0 1 x + 5 0 5 0 roads.
Now, this is a quadratic which is maximised when ∣ 5 0 . 5 − x ∣ is maximised. Since we cannot have x = 1 0 1 or x = 0 (Since this will connect all of the cities), we can either have x = 1 or x = 1 0 0 . This sets the total number of roads for which the country is not connected to be 4 9 5 0 at maximum. Therefore adding one road will connect the country, so our answer is 4 9 5 1 .