eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

A Minimum Land Price

A Minimum Land Price

Manager of ACM-ICPC Thailand Contest Council is planning to buy lands in Phuket to build the office building for national programming skill camp and programming contest that will be held on Phuket regularly in the future. The land price in Phuket is becoming more expensive in every year. The price increases in the exponential growth curves by a factor of year. If the land \textbf{i} whose initial cost is \textbf{L_i} bought in \textbf{t} years from now, its price will be \textbf{2x(L_i)^t}. All land prices are different. ACM-ICPC can buy only one land per year. You have to help the manager to buy the lands at lowest price within the budget of \textbf{5000} billions baht (\textbf{5x10^6} millions). For example, if we want to buy \textbf{3} lands with costs \textbf{7}, \textbf{2} and \textbf{10} in three consecutive years, the total price will be calculated as follow. \textbf{(2x7) + (2x2^2) + (2x10^3) = 2022} millions baht \InputFile First line of the input contains an integer \textbf{T} (\textbf{1} ≤ \textbf{T} ≤ \textbf{10}), the number of test cases. Each test case contains integer \textbf{L_i}which is the cost of land in million baht. There are less than \textbf{40} lands in each test case. The line contains \textbf{0} (zero) indicates the end of each test case. \OutputFile For each test case, print out the minimum price for purchasing all lands. If the total price exceeds the budget (\textbf{5000}billions baht), print out "\textbf{Too expensive}".
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
3
7
2
10
0
20
29
31
0
42
41
40
37
20
0
Вихідні дані #1
134
17744
Too expensive
Джерело ACM-ICPC Thailand National Programming Contest 2010, Prince of Songkla University Phuket Campus 24 August 2010