#C6975. Interconnecting Drop-Off Locations
Interconnecting Drop-Off Locations
Interconnecting Drop-Off Locations
You are given M drop-off locations and a truck that can directly travel between at most k sequential locations. Your task is to determine whether it is possible to interconnect all the drop-off locations under the given constraints.
Problem Statement:
For each test case, you are provided with two integers, M and k. You should output "Yes" if all locations can be interconnected and "No" otherwise.
The decision can be guided by the following observations:
- If M \le 2, the answer is always "Yes".
- If k = 1 and M > 2, the answer is "No" because a truck with limited reach can only directly connect adjacent stops.
- If k \ge M - 1, then any location can reach any other location directly, and the answer is "Yes".
- Otherwise, the answer is determined by additional conditions that can be summarized by the formula:
\(\text{if } M \% k == 0 \text{ or } (M \% k) \leq k\text{ then Yes, otherwise No.}\)
This problem tests your ability to correctly implement and simulate a decision function based on given constraints. Make sure your solution reads input from standard input (stdin) and writes the result to standard output (stdout).
inputFormat
The first line contains an integer T, the number of test cases. Each of the following T lines contains two space-separated integers: M (the number of drop-off locations) and k (the maximum number of sequential locations a truck can travel directly).
outputFormat
For each test case, output a single line with the answer: "Yes" if all drop-off locations can be interconnected according to the constraints, and "No" otherwise.
## sample3
4 1
5 2
6 3
No
Yes
Yes
</p>