Step 1: Work rates of A and B.
A’s rate of work = \( \frac{1}{10} \) work/day
B’s rate of work = \( \frac{1}{20} \) work/day
Step 2: Work done together.
For the first \( x \) days, A and B work together.
Total work done by A and B together in one day = \( \frac{1}{10} + \frac{1}{20} = \frac{3}{20} \) work/day.
The work done in \( x \) days is \( \frac{3x}{20} \).
Step 3: Work remaining when A leaves.
When A leaves after 2 days, work done = \( \frac{3 \times 2}{20} = \frac{6}{20} = \frac{3}{10} \).
Step 4: Work left.
So work left = \( 1 - \frac{3}{10} = \frac{7}{10} \).
Now, B alone does the remaining work.
B’s rate of work = \( \frac{1}{20} \) work/day.
Time taken by B to finish the remaining work = \( \frac{\frac{7}{10}}{\frac{1}{20}} = 14 \) days.
Step 5: Total time.
The total time taken = \( 2 \, \text{days (A and B together)} + 14 \, \text{days (B alone)} = 16 \) days.
Thus, the total time is 8 days.