#PU1501. USACO 2025 February Contest, Platinum — Problem 2. Transforming Pairs
USACO 2025 February Contest, Platinum — Problem 2. Transforming Pairs
USACO 2025 February Contest, Platinum — Problem 2. Transforming Pairs
题目描述
Answer () independent queries each of the following form: You are given four integers (). In one operation you can either do , or . Determine the minimum number of operations to transform into , or if it is impossible to do so, output .
输入格式
The first line contains . The next lines each contain four integers .
输出格式
The answer for each query on a separate line.
数据范围
(见题面原文)
样例
样例 1
4
5 -3 -1 -3
5 3 5 2
5 3 8 19
5 3 5 3
2
-1
3
0
First query: $(5,-3)\to (2,-3)\to (-1,-3)$
Second query: Impossible.
Third query: $(5,3) \to (8, 3) \to (8, 11) \to (8, 19)$
Fourth query: No operations necessary.