Two cars A and B start from place A at the same time and drive back and forth between places A and B continuously. The first head-on encounter is 40 kilometers away from A, and the second head-on encounter is 10 kilometers away from B. Find the distance between A and B.
A、B两辆汽车同时从甲地出发，在甲、乙两地间不断往返行驶．第一次迎面相遇距离甲地40公里，第二次迎面相遇距离乙地10公里．求甲、乙两地之间的距离．
<gadget id="calculator">3 * 40</gadget>
<output>120</output>

<gadget id="calculator">120 - 10</gadget>
<output>110</output>

<result>110</result>