Flowers instead of a tree
Time limit1sMemory limit128 MB
Choose the vase whose solid-of-revolution volume is closest to the target volume.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Sunyoung's second anniversary with her boyfriend is close. She wants to give him something special. He likes trees a lot, but Sunyoung thinks a tree is too big to hand over as a gift, so she settled on flowers.
Sunyoung believes that every flower has one vase volume that suits it best. She opened an online store to buy a vase, and each listing carries a photo and an outline function. Write a program that finds the vase closest to the volume she wants.
The outline of a vase is the function . Here is the vertical distance measured from the bottom of the vase, and the vase is the solid obtained by rotating this curve around the axis. The height of the vase is , so its volume is
Two different vases differ in volume by at least . The gap to the volume Sunyoung wants also differs from vase to vase by at least , so exactly one vase is the answer.
Input
The first line contains the volume that Sunyoung wants and the number of vases listed in the store. (, )
Each of the next lines contains , , and , which determine the outline function of one vase. ()
, , , and are real numbers and are sometimes written without a decimal point.
A vase with , , has volume 34.72348, and a vase with , , has volume 21.77966.
Output
Print the index of the vase whose volume differs least from the volume Sunyoung wants. The first vase has index 0.