Line of Sight
Time limit1sMemory limit128 MB
Given a rectangular floor, a rectangular blocker, and a camera sliding along one wall, find the percentage of open floor area hidden in the blocker's shadow.
- Level
Medium7 of 10
- Topics
- Geometry, Math, Implementation, Brute force
- Solved
- No attempts yet
Problem
The factory foreman at Widgets Inc. is worried that whenever he leaves the factory floor to do paperwork in his office, the workers on the floor start goofing off.
Management has decided to install a surveillance camera so the foreman can monitor the floor from his office. The camera is mounted on a rail that runs the entire length of one wall. It slides back and forth along the rail while also panning (rotating its angle of view), so it can see anything that could be seen by an observer standing anywhere along that wall.
During installation, someone notices that the large widget-stamping machine on the floor might block the camera's view, and that workers could hide in the machine's "shadow" to avoid being seen. Given the dimensions of the factory, the dimensions of the machine, and the machine's position, determine what percentage of the open floor space (the area not occupied by the machine) is hidden from the camera.
Input
The input contains several test cases, one per line. Each line holds six floating-point numbers:
- and are the dimensions of the rectangular factory floor. The camera rail runs along one of the walls of length . It is guaranteed that and .
- and are the dimensions of the rectangular widget-stamping machine, with and (the machine fits inside the factory).
- is the distance from the center of the machine to one of the walls of length , and is the distance from the center of the machine to the wall holding the camera rail. It is guaranteed that , , , and .
Input ends with a line of six numbers whose first value is ; that line is not processed.
Output
For each test case, print a single line in the form
P%
where is the percentage of the open floor space that is hidden from the camera, with . Print rounded to exactly one decimal digit.