a guest Aug 17th, 2019 608 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- Mr. Stark is the owner of Stark industries, a manufacturer of weaponry.
- A local Mafia group has hijacked one of the factories in the desert.
- The mafias want to transport the weapons from the factory to their base camp, and use a single truck to do it.
- But, every kilometer the truck travels with the weapons, one weapon falls off and breaks. The truck can only travel integral values of distance, and will
- lose 1 weapon for every km travelled.
- The weapons can be unloaded at any point from the truck, and can be picked up again later.
- Given the number of weapons X, max capacity of the truck Y and distance between the factory and the base Z, find the maximum number of
- weapons that can be transferred intact from the factory to the mafia base.
- Function Description:
- findMaxWeapons function takes the following parameters:
- X - the number of weapons
- Y - max capacity of the truck
- Z - distance between the factory and the base
- The function should return an integer representing the maximum number of weapons that can be transferred intact from the factory to the mafia base.
- 0 <= X <= 10^19
- 0 <= Y <= 10^19
- 0 <= Z <= 10^19
- Sample testcase 1:
- 500 ---> Number of weapons
- 1000 --> Max capacity of the truck
- 100 ---> Distance between the factory and the base.
- 400 ---> maximum number of weapons that can be transferred intact.
- Sample testcase 2:
RAW Paste Data