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.

Author: Kirito

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: \mathcal O(N^2), or \mathcal O(N \log N) with exponentiation by squaring.


Comments

There are no comments at the moment.