Go to diff to previous submission
// // File: mosquito.cc // Author: cteam035 // // Created on October 27, 2012, 11:23 AM // #include <cstdlib> #include <cmath> #include <iostream> using namespace std; // // // unsigned long long int max3 (unsigned long long int a, unsigned long long int b, unsigned long long int c) { unsigned long long int max; max = a>b?a:b; max = max>c?max:c; return max; } int main(int argc, char** argv) { unsigned long long int M,P,L,E,R,S,N; unsigned long long int a, out, max, e1, e2, e3; a=0; 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 = (unsigned long long int)floor(1.0*N/3); e2 = (unsigned long long int)ceil((1.0*(N-1))/3); e3 = (unsigned long long int)ceil(1.0*N/3); max = max3(e1,e2,e3); for (unsigned long long int i=0; i<max; i++ ) { if ( i < e1 ) out *= E; if ( i < e2 ) out = ( out/R ); if ( i < e3 ) out = ( out/S ); } cout << out << endl; } return (EXIT_SUCCESS); }