Naomi works in a data center and has designed a new computer broadcast network which has the following structure:
- There are
machines in total. - One of the machines is denoted as the "master" and is responsible for broadcasting new data.
- There are
one-directional wires between machines in the network arranged in a way such that the master machine can contact all the other machines.
Such a network would require minimal infrastructure and allow the master machine to broadcast information while being insulated from the other machines.
Unfortunately, the interns tasked with implementing the network made two mistakes. First, they mixed up the directions of some of the one-directional wires. Second, they used a low-quality wire with high signal loss, which means that a given machine can only communicate with machines at most
Nevertheless, Naomi remained optimistic: if she assigns multiple machines to the master role in such a way that each machine is at most
Input Specification
The input will contain 10 datasets. Each dataset begins with two integers
For the first 3 cases,
For the first 6 cases,
Output Specification
For each dataset, output the minimum number of master machines required to make the network operational.
Sample Input (Two Datasets Shown)
2 1
1 2
4 2
1 3
2 3
3 4
Sample Output
1
2
Educational Computing Organization of Ontario - statements, test data and other materials can be found at ecoocs.org
Comments
Hello stranger
Hi (not so obscure now, hopefully)