Predicting With Multiple Features
Distance alone stopped explaining Kestrel Freight's fuel bills once the fleet started mixing long motorway runs with short town rounds. The new rule reads several numbers about a job — distance, parcels carried, stops made, and so on — and each of them has its own weight, plus a single starting amount that applies to every job before any of those numbers are looked at. The rule has already been fitted; the quoting screen only has to run it over a batch of jobs.
Task: Print the cost the rule predicts for each job.
Input
The first line holds one integer k, how many numbers describe a job, where 1 <= k <= 50. The second line holds k + 1 numbers separated by single spaces: the starting amount first, then the k weights. The third line holds one integer n, the number of jobs. Then come n lines, each holding that job's k numbers separated by single spaces, in the same order as the weights.
Output
n lines, one per job, in the order the jobs arrived. Each line holds only the predicted cost rounded to 2 decimal places.
Example:
Input:
2
1 2 3
2
1 1
0 2
Output:
6.00
7.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