Try working backwards. Picture what would happen if only 2 pirates were left. Then picture what would happen if 3 pirates were left.
Let P represent the pirates. If 1 pirate were left 'P5' receives all the gold. If 2 pirates were left 'P5' would vote against 'P4', thus killing 'P4'. 'P5' knows that if he votes against 'P4', next round he will receive all the gold. P4 = 0gold P5 = 100gold If 3 Pirates were left. 'P3' knows that if it gets down to 2 pirates, 'P4' is a dead man. Therefore he knows 'P4' will vote for him not matter what therefore he can keep all the gold himself. And stay alive with a vote from 'P4' P3= 100 gold P4=0 gold P5= 0 gold With 4 pirates left. 'P4' needs 2 votes to stay alive. By giving 'P2' and 'P1' 1 gold each, they are guaranteed more than if it goes another round. P2=98 P3=0 P4=1 P5=1 With 5 pirates left. 'P5' (you) needs 2 more votes. Giving 'P4' 2 gold and 'P3' 1 gold will guarantee your survival. P1=97 P2=0 P3=1 P4=2 P5=0 Or P1=97 p2=0 p3=1 p4=0 p5=2 Therefore you can safely keep 97 gold.