Predicting With a Polynomial Model
The curved fuel rule is fitted and Kestrel Freight wants to quote with it. What came back from the fitting step is one starting amount plus one weight per power column — a weight for the distance, a weight for the distance squared, and so on for as many powers as the team asked for. Dispatch has a distance and wants the cost. The powers themselves are not supplied; only the distance is.
Task: Print the cost the fitted curve predicts for the given distance.
Input
The first line holds the fitted numbers separated by single spaces: the starting amount first, then the weights in power order — the weight for the plain distance, then for the distance squared, then cubed, and so on. Between 1 and 20 weights follow the starting amount. The second line holds the distance, which may have a decimal point.
Output
One line holding the predicted cost rounded to 2 decimal places, with no label.
Example:
Input:
1 2 3
2
Output:
17.00
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in