#P11846. [USACO25FEB] Transforming Pairs P
[USACO25FEB] Transforming Pairs P
Description
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 .
Input Format
The first line contains .
The next lines each contain four integers .
Output Format
The answer for each query on a separate line.
4
5 -3 -1 -3
5 3 5 2
5 3 8 19
5 3 5 3
2
-1
3
0
Hint
First query:
Second query: Impossible.
Third query:
Fourth query: No operations necessary.
SCORING:
- Input 2:
- Input 3:
- Input 4:
- Input 5:
- Input 6:
- Input 7:
- Input 8:
- Input 9:
- Input 10:
- Inputs 11-14:
- Inputs 15-19: No additional constraints.
京公网安备 11011102002149号