package com.zju.edu.cn.test;import java.io.File;import java.io.FileInputStream;import java.io.InputStream;import java.io.InputStreamReader;import java.util.Scanner;public class Test1 { static double forcast(int cycle , int period , double[] historical_data, int next_n, int next_m){ double A[][] = new double[period + next_n + 1][cycle]; for(int i = 0 ; i < period ; i ++) for(int j = 0 ; j < cycle ; j ++){ A[i][j] = historical_data[cycle * i + j]; } for(int i = 2 ; i <= next_n + 2 ; i ++) for(int j = 0 ; j < cycle ; j ++){ A[i][j] = (A[i -2][j] + A[i - 1][j])/2; } return A[next_n + period][next_m] ; } public static void main(String[] args) throws Exception{ File file = new File("D:\\in.txt"); InputStream is = new FileInputStream(file); Scanner in = new Scanner(new InputStreamReader(is)); int cycle , period,next_n,next_m; cycle = in.nextInt(); period = in.nextInt(); double historical_data[] = new double[cycle * period]; for(int i = 0 ; i < cycle * period; i ++) historical_data[i] = in.nextDouble(); next_n = in.nextInt(); next_m = in.nextInt(); double result = forcast(cycle, period,historical_data,next_n,next_m); System.out.println(result); } }