ADAFEAR - Ada and Primal Fear
As you might already know, Ada the Ladybug is a farmer. She grows many vegetables. During past months, her crop was attacked by colony of parasites. Each vegetable was attacked by Ai parasites. Ada has only limited answer for this. She bought a few bottles with Primal Fear, which is a mixture agains parasites.
Primal Fear works in following way: Each Primal Fear bottle has a power assigned to it (which is coincidentally a prime number). If it is applied to a vegetable with N parasites on it, either the N is divisible by its power, then the size of colony is reduced to N/power, or - if the size is not divisible - then it has no effect. Also, as soon as you apply mixture against a colony, the rest of colony will become immune agains Primal Fear.
Ada didn't know what to buy so she bought one bottle of every possible power. Can you find out the best strategy to fight agains parasites?
The first line of input will contain 1 ≤ N ≤ 1000, the number of vegetable.
The line will contain N numbers 1 ≤ Ai ≤ 2000, the size of colony on ith vegetable.
Print the minimum sum of sizes of colonies which could be achieved after applying Primal Fear optimally.
3 2 8 6
4 6 6 6 6
3 7 4 22
3 11 22 17
2 77 11
Last edit: 2018-07-15 15:56:59
Last edit: 2017-12-28 13:57:22
@Prateek Agarwal: Good day to you. Nope, since as you kill part of colony by Primal Fear, the rest of colony will become immune agains Primal Fear. Wish you a nice day ~ Good Luck!
Can more than one Primal Fears be applied on a single colony?