COCI '15 Contest 3 #1 Pot

View as PDF

Submit solution


Points: 5
Time limit: 1.0s
Memory limit: 64M

Problem types

The teacher has sent an e-mail to her students with the following task: "Write a program that will determine and output the value of X if given the statement:

X = number_1^{pot_1} + number_2^{pot_2} + \dots + number_N^{pot_N}

and it holds that number_1, number_2 to number_N are integers, and pot_1, pot_2 to pot_N one-digit integers."

Unfortunately, when the teacher downloaded the task to her computer, the text formatting was lost so the task transformed into a sum of N integers:

X = P_1 + P_2 + \dots + P_N

For example, without text formatting, the original task in the form of X = 21^2+125^3 became a task in the form of X = 212 + 1253. Help the teacher by writing a program that will, for given N integers from P_1 to P_N determine and output the value of X from the original task.

Please note: We know that it holds a^N = a \cdot a \cdot \dots \cdot a (N times).

Input Specification

The first line of input contains the integer N (1 \le N \le 10), the number of the addends from the task. Each of the following N lines contains the integer P_i (10 \le P_i \le 9\,999, i = 1 \dots N) from the task.

Output Specification

The first and only line of output must contain the value of X (X \le 1\,000\,000\,000) from the original task.

Sample Input 1

2
212
1253

Sample Output 1

1953566

Explanation for Sample Output 1

21^2 + 125^3 = 441 + 1\,953\,125 = 1\,953\,566.

Sample Input 2

5
23
17
43
52
22

Sample Output 2

102

Sample Input 3

3
213
102
45

Sample Output 3

10385

Comments

There are no comments at the moment.