Source code for submission s894

Go to diff to previous submission

mosquito.cpp

  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main()
  5. {
  6. unsigned long long M,P,L,E,R,S,N;
  7. unsigned long long Mt_3,Mt_2,Mt_1;
  8. while(1)
  9. {
  10. if(cin.eof()) break;
  11. cin >> M >> P >> L >> E >> R >> S >> N;
  12. //
  13. Mt_3 = P/S;
  14. Mt_2 = L/R/S;
  15. Mt_1 = M*E/R/S;
  16. //
  17. if(N == 1)
  18. M = Mt_3;
  19. else if(N == 2)
  20. M = Mt_2;
  21. else if(N == 3)
  22. M = Mt_1;
  23. else
  24. {
  25. for(int n = 3; n < N; n++)
  26. {
  27. //if(Mt_3 >= R*S) M = (Mt_3/R/S)*E;
  28. /*else */M = (Mt_3*E)/R/S;
  29. //
  30. Mt_3 = Mt_2;
  31. Mt_2 = Mt_1;
  32. Mt_1 = M;
  33. }
  34. }
  35. cout << M << '\n';
  36. }
  37. return 0;
  38. }

Diff to submission s738

mosquito.cpp

--- c4.s738.cteam054.mosquito.cpp.0.mosquito.cpp
+++ c4.s894.cteam054.mosquito.cpp.0.mosquito.cpp
@@ -4,6 +4,6 @@
 int main()
 {
-  int M,P,L,E,R,S,N;
-  int Mo,Po,Lo;
+  unsigned long long M,P,L,E,R,S,N;
+  unsigned long long Mt_3,Mt_2,Mt_1;
   while(1)
   {
@@ -11,11 +11,25 @@
     cin >> M >> P >> L >> E >> R >> S >> N;
     //
-    for(int n = 0; n < N; n++)
+    Mt_3 = P/S;
+    Mt_2 = L/R/S;
+    Mt_1 = M*E/R/S;
+    //
+    if(N == 1)
+      M = Mt_3;
+    else if(N == 2)
+      M = Mt_2;
+    else if(N == 3)
+      M = Mt_1;
+    else
     {
-      Mo = M; Po = P; Lo = L;
-      //
-      L = Mo*E;
-      P = Lo/R;
-      M = Po/S;
+      for(int n = 3; n < N; n++)
+      {
+        //if(Mt_3 >= R*S) M = (Mt_3/R/S)*E;
+        /*else */M = (Mt_3*E)/R/S;
+        //
+        Mt_3 = Mt_2;
+        Mt_2 = Mt_1;
+        Mt_1 = M;
+      }
     }
     cout << M << '\n';