Source code for submission s847

Go to diff to previous submission

mosquito.cpp

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <math.h>
  4.  
  5. int main()
  6. {
  7. int a[3];
  8. int b[3];
  9. int N;
  10.  
  11. while(scanf("%i %i %i %i %i %i %i",&a[0],&a[1],&a[2],&b[0],&b[1],&b[2], &N)==7)
  12. {
  13. int z = N % 3;
  14.  
  15. int x = a[z];
  16.  
  17. for (int i = N; i >= 1; i--)
  18. {
  19. z = i % 3;
  20. if (z == 0)
  21. x = x * b[0];
  22. else
  23. x = x / b[z];
  24. }
  25.  
  26. printf("%i\n",x);
  27.  
  28.  
  29. }
  30. return 0;
  31. }

Diff to submission s815

mosquito.cpp

--- c4.s815.cteam114.mosquito.cpp.0.mosquito.cpp
+++ c4.s847.cteam114.mosquito.cpp.0.mosquito.cpp
@@ -15,44 +15,13 @@
                 int x = a[z];
 
-                int y2 = b[1] * b[2];
-
-                int y1 = b[0];
-
-                for (int i = z; i>=1; i--)
-                {
-                        x = x / b[i];
-                }
-
-                /*int d;
-
-                if ((y1 != 0) && (N >= 3))
-                {
-
-                if (y1 > y2)
-                {
-                d = y1 / y2;
-                if (d != 1)                     
-                x = x * (d * (N / 3)); 
-                }
-                if (y1 < y2)
+                for (int i = N; i >= 1; i--)
                 {
-                d = y2 / y1;
-                if (d != 1)     
-                x = x / (d * (N / 3)); 
-                }
+                        z = i % 3;
+                        if (z == 0)
+                                x = x * b[0];
+                        else
+                                x = x / b[z];
                 }
 
-                else
-                {
-                if ( N >= 3)
-                x = 0;
-                }*/
-
-                        for (int i = 1; i <= N/3; i++)
-                        {
-                                x = (x*b[0]) / b[2] / b[1];
-                        }
-        
-
                 printf("%i\n",x);