fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. Scanner in = new Scanner(System.in);
  10. int n=in.nextInt();
  11. double[] A = new double[n];
  12. double[] B = new double[n];
  13. double[] C = new double[n+1];
  14. String ans = new String("");
  15. double inf = 1.0 / 0;
  16. C[n] = 0.0;
  17. int k=0;
  18. while(k<n){
  19. A[k] = in.nextDouble();
  20. k++;
  21. }
  22. String c=in.nextLine();
  23. int t=0;
  24. while(t<n){
  25. B[t]=in.nextDouble();
  26. t++;
  27. }
  28. for (int i=1; i<=n; i++){
  29. if(B[n-i]-C[n-i+1]!=0) C[n-i]=A[n-i]/(B[n-i]-C[n-i+1]);
  30. else C[n-i]=inf;
  31. }
  32. for (int i=0; i<=n; i++){
  33. ans+=Double.toString(C[i])+" ";
  34. }
  35. System.out.println(ans);
  36. }
  37. }
Success #stdin #stdout 0.13s 31216KB
stdin
10
2 -4 1 2 45.2 34 -23 34 56 7.09
 -3.4 4 4 -5 2.4 34.04 23 567 -3 4

stdout
-0.8567913942992066 -1.0657095142326265 0.24663198875517678 -0.05462407795229777 31.61389033873605 0.9702487256173882 -1.0025608427005548 0.05874893533055214 -11.733892090099529 1.7725 0.0