Source code for submission s786

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. int y2 = b[1] * b[2];
  18.  
  19. int y1 = b[0];
  20.  
  21. for (int i = z; i>=1; i--)
  22. {
  23. x = x / b[i];
  24. }
  25.  
  26. /*int d;
  27.  
  28. if ((y1 != 0) && (N >= 3))
  29. {
  30.  
  31. if (y1 > y2)
  32. {
  33. d = y1 / y2;
  34. if (d != 1)
  35. x = x * (d * (N / 3));
  36. }
  37. if (y1 < y2)
  38. {
  39. d = y2 / y1;
  40. if (d != 1)
  41. x = x / (d * (N / 3));
  42. }
  43. }
  44.  
  45. else
  46. {
  47. if ( N >= 3)
  48. x = 0;
  49. }*/
  50.  
  51. for (int i = 1; i <= N/3; i++)
  52. {
  53. x = (x*y1) / y2;
  54. }
  55.  
  56.  
  57. printf("%i\n",x);
  58.  
  59.  
  60. }
  61. return 0;
  62. }

Diff to submission s745

mosquito.cpp

--- c4.s745.cteam114.mosquito.cpp.0.mosquito.cpp
+++ c4.s786.cteam114.mosquito.cpp.0.mosquito.cpp
@@ -24,33 +24,39 @@
                 }
 
-                int d;
+                /*int d;
 
                 if ((y1 != 0) && (N >= 3))
                 {
 
-                        if (y1 > y2)
-                        {
-                                d = y1 / y2;
-                                if (d != 1)                     
-                                        x = x * (d * (N / 3)); 
-                        }
-                        if (y1 < y2)
-                        {
-                                d = y2 / y1;
-                                if (d != 1)     
-                                        x = x / (d * (N / 3)); 
-                        }
+                if (y1 > y2)
+                {
+                d = y1 / y2;
+                if (d != 1)                     
+                x = x * (d * (N / 3)); 
                 }
-        
-                else
+                if (y1 < y2)
                 {
-                        if ( N >= 3)
-                                x = 0;
+                d = y2 / y1;
+                if (d != 1)     
+                x = x / (d * (N / 3)); 
+                }
                 }
 
+                else
+                {
+                if ( N >= 3)
+                x = 0;
+                }*/
+
+                        for (int i = 1; i <= N/3; i++)
+                        {
+                                x = (x*y1) / y2;
+                        }
+        
+
                 printf("%i\n",x);
 
 
-}       
-return 0;
+        }       
+        return 0;
 }
\ No newline at end of file