Editorial for THICC '17 P1 - Carol's Carnivorous Plants
Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.
Submitting an official solution before solving the problem yourself is a bannable offence.
Author:
Since all of the prices are integers, and are all positive, you want the cheapest one to have the largest exponent, and the most expensive one to have the smallest exponent. Thus we can sort all of the prices, and then compute the powers as necessary.
Time Complexity: , or with exponentiation by squaring.
Comments