Advertisement
Guest User

Untitled

a guest
Nov 15th, 2012
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SimpleCalc {
  4.  
  5. public static void main(String[] args) {
  6. Scanner in = new Scanner(System.in);
  7.  
  8. while (in.hasNext()) {
  9. int n = in.nextInt();
  10.  
  11.  
  12. for (int i = 0; i < n; i++) {
  13. System.out.println();
  14. int x = in.nextInt();
  15. double a0 = in.nextDouble();
  16. double af = in.nextDouble();
  17.  
  18. double a1 = 0;
  19.  
  20. double c = 0;
  21. double k = 0;
  22. for (int j = 0; j < x; j++) {
  23. c = in.nextDouble();
  24. c = (double) (-1)
  25. * ((double) 2 * (double) (x - j) * (double) c );
  26.  
  27. k = (double) c + (double) k;
  28.  
  29. }
  30. k=(double)k/(double)(x+1);
  31. a1 = ((double) (x * a0) + af) / (double) (x + 1) + (double) k;
  32. System.out.printf("%.2f\n", a1);
  33.  
  34. }
  35.  
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement