5. At this moment, $A$ has three times as many years as $B$ had when $A$ had as many years as $B$ has now. When $B$ will have as many years as $A$ has now, the two of them will together have 70 years. How old is each of them?

## Second Grade - B Category
5. Let $A$ now be $x$ years old, and let $B$ be $y$ years old. Therefore, $A$ is older than $B$ by $x-y$ years. When $A$ was $y$ years old, $B$ was $y-(x-y) = 2y - x$ years old, so the first condition from the problem can be written as $x = 3(2y - x)$, which simplifies to $2x = 3y$. When $B$ is $x$ years old, $A$ will be $x + (x - y) = 2x - y$ years old, so the second condition from the problem can be written as $2x - y + x = 70$, or $3x - y = 70$. Solving the system, we get $x = 30$ and $y = 20$.

## Second Grade - B Category