#USACOC2223A. Searching for Soulmates
Searching for Soulmates
当前没有测试数据。
Description
Farmer John's cows each want to find their soulmate -- another cow with similarcharacteristics with whom they are maximally compatible. Each cow's personality is described by an integer . Two cows with the same personality are soulmates.A cow can change her personality via a "change operation" by multiplying by ,dividing by (if is even), or adding .
Farmer John initially pairs his cows up in an arbitrary way. He is curious howmany change operations would be needed to make each pair of cows into soulmates.For each pairing, decide the minimum number of change operations the first cowin the pair must make to become soulmates with the second cow.
Input Format
The first line contains , the number of pairs of cows. Eachof the remaining lines describes a pair of cows in terms of two integersgiving their personalities. The first number indicates the personality of thecow that must be changed to match the second.
Output Format
Please write lines of output. For each pair, print the minimum number ofoperations required for the first cow to make her personality match that of thesecond.
6
31 13
12 8
25 6
10 24
1 1
997 120
6
31 13
12 8
25 6
10 24
1 1
997 120
Scoring
- Test cases 1-4 satisfy .
- Test cases 5-12 satisfy no additional constraints.
Problem Credit
Problem credits: Quanquan Liu