mosquito.cpp
//
// File: mosquito.cc
// Author: cteam035
//
// Created on October 27, 2012, 11:23 AM
//
#include <cstdlib>
#include <cmath>
#include <iostream>
using namespace std;
//
//
//
int max3 (int a, int b, int c) {
int max;
max = a>b?a:b;
max = max>c?max:c;
return max;
}
int main(int argc, char** argv) {
int M,P,L,E,R,S,N;
double a=0;
long long int out, max, e1, e2, e3;
while ( cin >> M >> P >> L >> E >> R >> S >> N ) {
switch (N%3){
case 0:
a=M;
break;
case 1:
a=P;
break;
case 2:
a=L;
break;
}
out = a;
e1=(N/3);
e2=ceil((1.0*N-1)/3);
e3=ceil(1.0*N/3);
max = max3(e1,e2,e3);
for ( int i=0; i<max; i++ ) {
if ( i < e1 )
out *= E;
if ( i < e2 )
out /= R;
if ( i < e3 )
out /= S;
}
// b=pow(E,);
// cout << b << " " << c << " " << d << " " << endl;
// c=pow(R,ceil((1.0*N-1)/3));
// cout << b << " " << c << " " << d << " " << endl;
// d=pow(S,ceil(1.0*N/3));
// cout << b << " " << c << " " << d << " " << endl;
cout << out << endl;
}
return (EXIT_SUCCESS);
}