Pascal:
function power(a: integer; n: integer): integer;
begin
if n = 0 then
power := 1
else if n mod 2 = 0 then
power := sqr(power(a, n div 2))
else
power := power(a, n - 1) * a;
end;
var
a: array[0 .. 4] of integer;
x, i, res: integer;
begin
res := 0;
for i := 4 downto 0 do
read(a[i]);
readln(x);
for i := 4 downto 0 do
inc(res, a[i] * power(x, i));
writeln(res)
end.