Source code for submission s862

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. if (a[6] > 0) {
  32. for (int i = 0; i < a[6]; i++) {
  33. pom = a[0];
  34. if (a[5] > 0) {
  35. a[0] = Math.round(a[1] / a[5]);
  36. } else {
  37. a[0] = a[1];
  38. }
  39. if (a[4] > 0) {
  40. a[1] = Math.round(a[2] / a[4]);
  41. } else {
  42. a[1] = a[2];
  43. }
  44. a[2] = pom * a[3];
  45.  
  46. }
  47. }
  48. result.add(a[0]);
  49. res = sc.nextLine();
  50. }
  51. for (Integer string : result) {
  52. System.out.println(string);
  53. }
  54.  
  55.  
  56. }
  57. }
  58.  

Diff to submission s856

Mosquito.java

--- c4.s856.cteam124.mosquito.java.0.Mosquito.java
+++ c4.s862.cteam124.mosquito.java.0.Mosquito.java
@@ -22,27 +22,35 @@
         String res = sc.nextLine();
         List<Integer> result = new LinkedList<Integer>();
-        int[] a =  new int[7];
+        int[] a = new int[7];
         int pom = 0;
-       while (!"".equals(res)){
-        String[] ress = res.split(" ");
-           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];                  
-                        
+        while (!"".equals(res)) {
+            String[] ress = res.split(" ");
+            for (int i = 0; i < ress.length; i++) {
+                a[i] = Integer.parseInt(ress[i]);
+            }
+            if (a[6] > 0) {
+                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(a[0]);
+            res = sc.nextLine();
         }
-       result.add(a[0]);
-       res = sc.nextLine();       
-       }
         for (Integer string : result) {
             System.out.println(string);
         }
-        
+
 
     }