Source code for submission s1001

Mosquito.java

  1. /*
  2.  * To change this template, choose Tools | Templates
  3.  * and open the template in the editor.
  4.  */
  5.  
  6. /**
  7.  *
  8.  * @author cteam040
  9.  */
  10. import java.util.*;
  11. import java.io.*;
  12.  
  13. public class Mosquito {
  14.  
  15. public static long m, p, l, e, r, s, n;
  16.  
  17. public static void main(String args[]) throws IOException {
  18. String ln;
  19.  
  20. while((ln = br.readLine()) != null) {
  21. st = new StringTokenizer(ln);
  22. m = Long.parseLong(st.nextToken());
  23. p = Long.parseLong(st.nextToken());
  24. l = Long.parseLong(st.nextToken());
  25. e = Long.parseLong(st.nextToken());
  26. r = Long.parseLong(st.nextToken());
  27. s = Long.parseLong(st.nextToken());
  28. n = Long.parseLong(st.nextToken());
  29.  
  30. System.out.println(compute(n)[0]);;
  31. }
  32. }
  33.  
  34. public static long[] compute(long n) {
  35. if(n == 0) {
  36. return new long[]{m, p, l};
  37. }
  38. long [] lowerLvl = compute(n - 1);
  39.  
  40. return new long[]{(long)Math.floor((double)lowerLvl[1]/s), (long)Math.floor((double)lowerLvl[2]/r), lowerLvl[0]*e};
  41. }
  42.  
  43. }
  44.