Source code for submission s1002

Go to diff to previous submission

Mosquito.java

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

Diff to submission s1000

Mosquitko.java