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; // // // long long int max3 (long long int a, long long int b, long long int c) { int max; max = a>b?a:b; max = max>c?max:c; return max; } int main(int argc, char** argv) { long long int M,P,L,E,R,S,N; 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 = (N/3); e2 = (long long int)ceil((1.0*N-1)/3); e3 = (long long int)ceil(1.0*N/3); max = max3(e1,e2,e3); for ( 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); }
--- c4.s697.cteam035.mosquito.cpp.0.mosquito.cpp +++ c4.s1258.cteam035.mosquito.cpp.0.mosquito.cpp @@ -14,5 +14,5 @@ // -int max3 (int a, int b, int c) { +long long int max3 (long long int a, long long int b, long long int c) { int max; max = a>b?a:b; @@ -23,7 +23,7 @@ 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; + long long int M,P,L,E,R,S,N; + long long int a, out, max, e1, e2, e3; + a=0; while ( cin >> M >> P >> L >> E >> R >> S >> N ) { switch (N%3){ @@ -39,22 +39,16 @@ } out = a; - e1=(N/3); - e2=ceil((1.0*N-1)/3); - e3=ceil(1.0*N/3); + e1 = (N/3); + e2 = (long long int)ceil((1.0*N-1)/3); + e3 = (long long int)ceil(1.0*N/3); max = max3(e1,e2,e3); - for ( int i=0; i<max; i++ ) { + for ( long long int i=0; i<max; i++ ) { if ( i < e1 ) out *= E; if ( i < e2 ) - out /= R; + out = ( out/R ); if ( i < e3 ) - out /= S; + out = ( 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; }