Minimum of two sequences

87 Views Asked by At

I would like to solve the following problem:

Peter has 2 accounts in a bank, each with an integral number of dollars $A$ and $B$. He is only allowed to transfer money from one account to another so that the amount of money in the latter is doubled. What is the minimum value of $\mid A_i-B_i \mid$ that Peter can get ?

I don't really know how to solve this problem. If we denote $f(A,B) = \min \mid A_i - B_i \mid$, then for example we have:

$$f(10, 17) = 1$$ $$f(4, 100) = 8$$ $$f(3, 7) = 2$$

But I am not able to find any logic. If $ A = 2B$ then $f(A,B) = B$. Otherwise I tried writing: $B = qA + r$, but wasn't able to find a way through. Any ideas ?

1

There are 1 best solutions below

0
On

This is not a complete answer, but rather an explanation of a convenient way to view the problem that might lead to a solution.

We can simplify the problem as follows:

  • If $A$ and $B$ have a common factor, $d$, then the answer is $d$ times the answer to the same question for $A/d$ and $B/d$. Therefore, we can assume $A$ and $B$ are coprime.

  • If $A$ and $B$ are both odd, then after one step they will be both even, which means we can divide by $2$. Therefore, we can assume that $A$ and $B$ are not both odd.

The only remaining cases are when one of $A$ and $B$ is odd, and the other is even. This property will persist as we make moves.

If we are currently in the state $(A,B)$, where $A<B$, then the next move is to $$ (A,B)\longrightarrow (2A,B-A)=(2A,2B-(A+B)) $$ Let us look at this transformation modulo $(A+B)$. For example, in the case where $(A,B)=(10,17)$, we are considering the problem modulo $27$. Since $A+B\equiv 0\pmod{A+B}$, the above can be written as $$ (A,B)\longrightarrow (2A,2B)\pmod{A+B} $$ In other words, we are simply doubling both coordinates modulo $(A+B)$. This makes the problem very simple to analyze. First of all, modulo $A+B$, the state is equal to $(A,B)\equiv (A,-A)\pmod{A+B}$, so the entire situation is summarized by the first coordinate alone. After $k$ moves, the state of the problem will be $$ (2^k A,-2^kA) $$ The difference between these two is smallest when $2^kA\equiv (A+B\pm 1)/2$. The question is, how close does $2^kA\pmod {A+B}$ come to $(A+B+1)/2$?

As long as $2$ is a primitive root, then then $2^k$ will assume every value modulo $(A+B)$, so you can certainly bring $A$ and $B$ to their closest possible absolute difference of one. But there are not a lot of general things that can be said about the powers of $2$ modulo a general odd number, so I cannot think about how to proceed in general.