Source code for submission s856

Go to diff to previous submission

Mosquito.java

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5. package mosquito;
  6.  
  7. import java.util.LinkedList;
  8. import java.util.List;
  9. import java.util.Scanner;
  10.  
  11. /**
  12.  *
  13.  * @author student
  14.  */
  15. public class Mosquito {
  16.  
  17. /**
  18.   * @param args the command line arguments
  19.   */
  20. public static void main(String[] args) {
  21. Scanner sc = new Scanner(System.in);
  22. String res = sc.nextLine();
  23. List<Integer> result = new LinkedList<Integer>();
  24. int[] a = new int[7];
  25. int pom = 0;
  26. while (!"".equals(res)){
  27. String[] ress = res.split(" ");
  28. for (int i = 0; i < ress.length; i++) {
  29. a[i] = Integer.parseInt(ress[i]);
  30. }
  31. for (int i = 0; i < a[6]; i++) {
  32. pom = a[0];
  33. if(a[5] > 0) a[0] = Math.round(a[1] / a[5]);
  34. else a[0] = a[1];
  35. if(a[4] >0) a[1] = Math.round(a[2] / a[4]);
  36. else a[1] = a[2];
  37. a[2] = pom*a[3];
  38.  
  39. }
  40. result.add(a[0]);
  41. res = sc.nextLine();
  42. }
  43. for (Integer string : result) {
  44. System.out.println(string);
  45. }
  46.  
  47.  
  48. }
  49. }
  50.  

Diff to submission s803

Mosquito.java

--- c4.s803.cteam124.mosquito.java.0.Mosquito.java
+++ c4.s856.cteam124.mosquito.java.0.Mosquito.java
@@ -22,26 +22,21 @@
         String res = sc.nextLine();
         List<Integer> result = new LinkedList<Integer>();
-        
-        int pom, m, p, l, e, r, s, n;
+        int[] a =  new int[7];
+        int pom = 0;
        while (!"".equals(res)){
         String[] ress = res.split(" ");
-        m = Integer.parseInt(ress[0]);
-        p = Integer.parseInt(ress[1]);
-        l = Integer.parseInt(ress[2]);
-        e = Integer.parseInt(ress[3]);
-        r = Integer.parseInt(ress[4]);
-        s = Integer.parseInt(ress[5]);
-        n = Integer.parseInt(ress[6]);
-        
-        for (int i = 0; i < n; i++) {
-            pom = m;
-            if(s > 0) m = Math.round(p / s);
-            else m = p;
-            if(r >0)  p = Math.round(l / r);
-            else p = l;
-            l = pom*e;                  
+           for (int i = 0; i < ress.length; i++) {
+               a[i] = Integer.parseInt(ress[i]);
+           }
+        for (int i = 0; i < a[6]; i++) {
+            pom = a[0];
+            if(a[5] > 0) a[0] = Math.round(a[1] / a[5]);
+            else a[0] = a[1];
+            if(a[4] >0)  a[1] = Math.round(a[2] / a[4]);
+            else a[1] = a[2];
+            a[2] = pom*a[3];                  
                         
         }
-       result.add(m);
+       result.add(a[0]);
        res = sc.nextLine();       
        }