Source code for submission s835

Go to diff to previous submission

mosq.java

  1.  
  2. import java.io.BufferedReader;
  3.  
  4. /*
  5.  * To change this template, choose Tools | Templates
  6.  * and open the template in the editor.
  7.  */
  8. import java.io.IOException;
  9. import java.io.InputStreamReader;
  10. import java.util.ArrayList;
  11. import java.util.LinkedList;
  12. import java.util.StringTokenizer;
  13.  
  14.  
  15.  
  16. /**
  17.  *
  18.  * @author cteam022
  19.  */
  20. public class mosq {
  21.  
  22.  
  23. /**
  24.   * @param args the command line arguments
  25.   */
  26. public static void main(String[] args) throws IOException {
  27. mosq g = new mosq();
  28. while(true){g.uloha();}
  29. }
  30.  
  31. void uloha() throws IOException{
  32. if(!input.ready()){System.exit(0);}
  33. st = new StringTokenizer(input.readLine());
  34. int M = Integer.valueOf(st.nextToken());
  35. int P = Integer.valueOf(st.nextToken());
  36. int L = Integer.valueOf(st.nextToken());
  37. int E = Integer.valueOf(st.nextToken());
  38. int R = Integer.valueOf(st.nextToken());
  39. int S = Integer.valueOf(st.nextToken());
  40. int N = Integer.valueOf(st.nextToken());
  41.  
  42. int C[] = new int[N+1];
  43. C[0] = M;
  44. C[1] = P/S;
  45. C[2] = L/(R*S);
  46. if(N >= 3) {
  47. for(int i = 3; i <= N; i++) {
  48. C[i] = (E*C[i-3])/(R*S);
  49. }
  50. }
  51. System.out.println(C[N]);
  52. }
  53.  
  54. }
  55.  

Diff to submission s810

mosq.java

--- c4.s810.cteam022.mosquito.java.0.mosq.java
+++ c4.s835.cteam022.mosquito.java.0.mosq.java
@@ -43,10 +43,11 @@
      
         int C[] = new int[N+1];
-             
         C[0] = M;
         C[1] = P/S;
         C[2] = L/(R*S);
-        for(int i = 3; i <= N; i++) {
-            C[i] = (E*C[i-3])/(R*S);
+        if(N >= 3) {
+            for(int i = 3; i <= N; i++) {
+                C[i] = (E*C[i-3])/(R*S);
+            }
         }
         System.out.println(C[N]);