A. Soldier and Bananas time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output A soldier wants to buy w bananas in the shop. He has to pay k dollars for the first banana, 2k dollars for the second…