Stacking Curvy Blocks
Time limit2sMemory limit256 MB
Given two cubic edges on [0,1], lower the upper curve until it touches the lower one and report the largest vertical gap between them.
- Level
Medium4 of 10
- Topics
- Math
- Solved
- No attempts yet
Problem
You are doing construction work, and to save money you bought discounted irregular blocks. Each irregular block is rectangular except for one edge, which is curvy. You wedge the irregular blocks between stacks of ordinary blocks so they cannot slide sideways or rotate. The lower irregular block sits with its curvy edge pointing up, and the one above it sits with its curvy edge pointing down. The upper block is lowered straight down until it just touches the lower one.
You want to know how well the two blocks fit together. At the moment the upper block just touches the lower one, the fit quality is the largest vertical gap between the upper edge of the bottom block and the lower edge of the top block.
Every block is one unit wide. Both curvy edges are cubic polynomials in , with the left edge of a block at and the right edge at .
Input
The input holds several test cases and ends at end of file. There are at most 500 test cases.
Each test case is two lines, and each line holds four real numbers.
The first line gives . The upper edge of the bottom block has the shape of for .
The second line gives . The lower edge of the top block has the shape of for .
No input value has magnitude greater than 50000.
Output
For each test case, print the fit quality on its own line.
Round the value to six digits after the decimal point and always print all six digits, even when they are zero. A value of 3 prints as 3.000000.
No test case has an answer sitting on a boundary where the sixth digit could round either way.