Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SimpleCalc {
- public static void main(String[] args) {
- Scanner in = new Scanner(System.in);
- while (in.hasNext()) {
- int n = in.nextInt();
- boolean cp = false;
- for (int i = 0; i < n; i++) {
- if (cp == true)
- System.out.println();
- cp = true;
- int x = in.nextInt();
- double a0 = in.nextDouble();
- double af = in.nextDouble();
- double a1 = 0;
- double c = 0;
- double k = 0;
- for (int j = 0; j < x; j++) {
- c = in.nextDouble();
- c = (double) (-1)
- * ((double) 2 * (double) (x - j) * (double) c );
- k = (double) c + (double) k;
- }
- k=(double)k/(double)(x+1);
- a1 = ((double) (x * a0) + af) / (double) (x + 1) + (double) k;
- System.out.printf("%.2f\n", a1);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement