Source code for submission s815

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*b[0]) / b[2] / b[1];
  54. }
  55.  
  56.  
  57. printf("%i\n",x);
  58.  
  59.  
  60. }
  61. return 0;
  62. }

Diff to submission s786

mosquito.cpp

--- c4.s786.cteam114.mosquito.cpp.0.mosquito.cpp
+++ c4.s815.cteam114.mosquito.cpp.0.mosquito.cpp
@@ -51,5 +51,5 @@
                         for (int i = 1; i <= N/3; i++)
                         {
-                                x = (x*y1) / y2;
+                                x = (x*b[0]) / b[2] / b[1];
                         }