Source code for submission s700

Go to diff to previous submission

mosquitos.cpp

  1. #include <cstdio>
  2. #include <cstdlib>
  3. #include <cstring>
  4.  
  5. int main( int argc, char ** argv ) {
  6.  
  7. int M, P, L, E, R, N, S;
  8.  
  9. while( scanf("%d %d %d %d %d %d %d", &M, &P, &L, &E, &R, &S, &N) == 7) {
  10. int initc = N % 3;
  11.  
  12. int i;
  13.  
  14. int Mnew, Mold, Pnew, Pold, Lnew, Lold;
  15.  
  16. Mnew = Mold = M;
  17. Pnew = Pold = P;
  18. Lnew = Lold = L;
  19.  
  20.  
  21. for (i=0; i<initc; i++) {
  22. Mnew = Pold / S;
  23. Pnew = Lold / R;
  24. Lnew = Mold * E;
  25.  
  26. Lold = Lnew;
  27. Pold = Pnew;
  28. Lold = Lnew;
  29.  
  30. }
  31.  
  32. for (; i<N; i+=3) {
  33. Mnew*=E;
  34. Mnew/=R;
  35. Mnew/=S;
  36. }
  37.  
  38. printf("%d\n", Mnew);
  39. }
  40.  
  41. return 0;
  42. }

Diff to submission s675

mosquitos.cpp

--- c4.s675.cteam005.mosquito.cpp.0.mosquitos.cpp
+++ c4.s700.cteam005.mosquito.cpp.0.mosquitos.cpp
@@ -17,4 +17,5 @@
     Pnew = Pold = P;
     Lnew = Lold = L;
+      
     
     for (i=0; i<initc; i++) {
@@ -22,4 +23,9 @@
       Pnew = Lold / R;
       Lnew = Mold * E;
+      
+      Lold = Lnew;
+      Pold = Pnew;
+      Lold = Lnew;
+      
     }