Source code for submission s1285

Go to diff to previous submission

mosquito.cpp

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

Diff to submission s894

mosquito.cpp

--- c4.s894.cteam054.mosquito.cpp.0.mosquito.cpp
+++ c4.s1285.cteam054.mosquito.cpp.0.mosquito.cpp
@@ -4,34 +4,34 @@
 int main()
 {
-  unsigned long long M,P,L,E,R,S,N;
-  unsigned long long Mt_3,Mt_2,Mt_1;
+  unsigned M,P,L,E,R,S,N;
+  unsigned Mo,Po,Lo;
+  
+  M = 0;
+  P = 0;
+  L = 0;
+  E = 0;
+  R = 0;
+  S = 0;
+  N = 0;
+  
+  Mo = 0;
+  Po = 0;
+  Lo = 0;
+  
   while(1)
   {
-    if(cin.eof()) break;
-    cin >> M >> P >> L >> E >> R >> S >> N;
-    //
-    Mt_3 = P/S;
-    Mt_2 = L/R/S;
-    Mt_1 = M*E/R/S;
+    cin >> M;
+    if(!cin.good()) break;
+    cin >> P >> L >> E >> R >> S >> N;
     //
-    if(N == 1)
-      M = Mt_3;
-    else if(N == 2)
-      M = Mt_2;
-    else if(N == 3)
-      M = Mt_1;
-    else
+    for(int n = 0; n < N; n++)
     {
-      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;
-      }
+      Mo = M; Po = P; Lo = L;
+      //
+      L = Mo*E;
+      P = Lo/R;
+      M = Po/S;
     }
-    cout << M << '\n';
+    cout << M << endl;
   }
   return 0;