Or solve this problem and you'll be the second smartest player on pimd behind me who already solved it : A player makes "P" plunder every time he hits his farm and has a "Z" percent chance of winning. That player can increase his chance of winning by "T"% for every "W" he spends on items. He is weakened each time he attacks and makes "L"% less of his max plunder after each attack. He also has a "R"% less chance to win after each attack since he is being weakened. How much money should he spend on items for the Nth attack to maximize profit?