A certain gentleman initially had 512 yuan, and bet with others 8 times, but he won 4 times and lost 4 times. He did not know the order of winning and losing. If each bet is half of the remaining money before the bet, what is the final result?
某君最初有512元，和人打赌8次，结果赢了4次，输了4次，不知输赢次序，若每次赌金是此次赌前的余钱的一半，则最后结果是？
<gadget id="calculator">1 / 2</gadget>
<output>1/2 = around 0.5</output>

<gadget id="calculator">1 + (1/2)</gadget>
<output>3/2 = around 1.5</output>

<gadget id="calculator">512 * (3/2) * (3/2) * (3/2) * (3/2) * (1/2) * (1/2) * (1/2) * (1/2)</gadget>
<output>162</output>

<gadget id="calculator">512 - 162</gadget>
<output>350</output>

<result>350</result>