its easy lah, just think about it. its only a trick of mind and i will tell u the answer here.
He borrowed $100 and he bought the shoes by $ 97 so:
97/2 = $ 48.5 for each of them plus he gave them $1 each after that, then the total with each one of them (the two who gave him the money) $49.5
then $49.5 + $49.5 = $99, and he kept $1 for himself, then the total will be $100.
just took me 1 min to solve it, hahaha.