← 返回 twosigma 的题目列表Linear Interpolation
类型:online_judge
Given a series of data points and a target x value, use linear interpolation to predict the y value corresponding to the target x. Assume all points lie on a straight line. Use the linear interpolation formula for prediction and explain how to handle different y values for the same x value. Input format: The first line contains two integers n and m, representing the number of data points and the number of target x values. The next n lines each contain two float numbers representing an x and y value of a data point. The last m lines each contain a float number representing a target x value. Output the predicted y value for each target x.
Example
Input
3 2
0 0
1 1
2 2
0.5
1.5