Source code for submission s697

mosquito.cpp

  1. //
  2. // File: mosquito.cc
  3. // Author: cteam035
  4. //
  5. // Created on October 27, 2012, 11:23 AM
  6. //
  7.  
  8. #include <cstdlib>
  9. #include <cmath>
  10. #include <iostream>
  11. using namespace std;
  12. //
  13. //
  14. //
  15.  
  16. int max3 (int a, int b, int c) {
  17. int max;
  18. max = a>b?a:b;
  19. max = max>c?max:c;
  20. return max;
  21. }
  22.  
  23. int main(int argc, char** argv) {
  24.  
  25. int M,P,L,E,R,S,N;
  26. double a=0;
  27. long long int out, max, e1, e2, e3;
  28. while ( cin >> M >> P >> L >> E >> R >> S >> N ) {
  29. switch (N%3){
  30. case 0:
  31. a=M;
  32. break;
  33. case 1:
  34. a=P;
  35. break;
  36. case 2:
  37. a=L;
  38. break;
  39. }
  40. out = a;
  41. e1=(N/3);
  42. e2=ceil((1.0*N-1)/3);
  43. e3=ceil(1.0*N/3);
  44. max = max3(e1,e2,e3);
  45. for ( int i=0; i<max; i++ ) {
  46. if ( i < e1 )
  47. out *= E;
  48. if ( i < e2 )
  49. out /= R;
  50. if ( i < e3 )
  51. out /= S;
  52. }
  53. // b=pow(E,);
  54. // cout << b << " " << c << " " << d << " " << endl;
  55. // c=pow(R,ceil((1.0*N-1)/3));
  56. // cout << b << " " << c << " " << d << " " << endl;
  57. // d=pow(S,ceil(1.0*N/3));
  58. // cout << b << " " << c << " " << d << " " << endl;
  59. cout << out << endl;
  60. }
  61.  
  62.  
  63.  
  64.  
  65. return (EXIT_SUCCESS);
  66. }
  67.  
  68.