Grass Seed Inc.
InterviewTime limit2sMemory limit512 MB
Given the cost per square metre and a list of rectangular lawns, print the total cost of seeding all of them, rounded to seven decimals.
- Level
Easy1 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Years ago, after another wasted day in an office cubicle fighting one more buzzword-filled JavaScript framework, Janice the engineer looked out of the window and decided it was time for a change. She traded her keyboard and mouse for a pitchfork and a spade and started a gardening company.
After years of outdoor work Janice runs the largest landscaping company in the South West, and she has just won a large contract to sow lawns for wealthy landowners. Each contract lists the size of every lawn that needs seeding and the price of the seed for one square metre. Work out how much the seed costs in total.
Every lawn is a rectangle, so its area is its width times its length.
Input
The first line contains a real number (), the cost of sowing one square metre of lawn.
The second line contains an integer (), the number of lawns to sow.
Each of the next lines contains two real numbers, the width () and the length () of one lawn.
Output
Print the total cost of sowing all the lawns on one line, rounded to seven decimal places. Always print all seven digits after the decimal point, padding with zeros when needed.
No input puts the exact value exactly on a rounding boundary.