Loading problem...
You are tasked with identifying a single contaminated container among a collection of containers liquid samples in a laboratory experiment. To detect the contamination, you can use biological test subjects that will exhibit a reaction exactly reactionTime minutes after exposure to the contaminated substance.
Your experiment has a strict time limit of totalTime minutes to conclusively identify which container holds the contaminated sample.
The testing protocol works as follows:
Given the number of containers, the reactionTime, and the totalTime available, determine the minimum number of test subjects needed to guarantee identification of the contaminated container within the allotted time frame.
Key Insight: Each test subject encodes information through its potential states across multiple testing rounds. If you have T testing rounds available, each test subject can be in one of T + 1 possible states: it could react in round 1, round 2, ..., round T, or never react at all. This multi-dimensional state space is the key to minimizing the number of test subjects required.
containers = 4
reactionTime = 15
totalTime = 152With only 15 minutes total and 15 minutes required for reaction observation, we can perform exactly 1 testing round. Each test subject has 2 possible outcomes: reacts or doesn't react. With 2 test subjects, we have 2² = 4 possible combined outcomes (both react, only first reacts, only second reacts, neither reacts), which is exactly enough to distinguish 4 containers.
Example strategy: Expose first subject to containers 1 and 2. Expose second subject to containers 2 and 3.
containers = 4
reactionTime = 15
totalTime = 302With 30 minutes total and 15 minutes per reaction cycle, we can perform 2 testing rounds. Each test subject now has 3 possible states: reacts in round 1, reacts in round 2, or never reacts. With 2 test subjects, we have 3² = 9 possible combined outcomes, which is more than sufficient to distinguish 4 containers.
This demonstrates that more testing rounds allow each test subject to encode more information, potentially reducing the total subjects needed.
containers = 1
reactionTime = 1
totalTime = 10When there is only 1 container, no testing is required—the sole container must be the contaminated one by default. Therefore, 0 test subjects are needed.
Constraints