Line of Sight

Time limit1sMemory limit128 MB

Summary
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:

w1  h1  w2  h2  x  yw_1 \; h_1 \; w_2 \; h_2 \; x \; y

  • w1w_1 and h1h_1 are the dimensions of the rectangular factory floor. The camera rail runs along one of the walls of length w1w_1. It is guaranteed that 0<w1≤10000.00 < w_1 \le 10000.0 and 0<h1≤10000.00 < h_1 \le 10000.0.
  • w2w_2 and h2h_2 are the dimensions of the rectangular widget-stamping machine, with 0<w2<w10 < w_2 < w_1 and 0<h2≤h10 < h_2 \le h_1 (the machine fits inside the factory).
  • xx is the distance from the center of the machine to one of the walls of length h1h_1, and yy is the distance from the center of the machine to the wall holding the camera rail. It is guaranteed that 0<x−w220 < x - \frac{w_2}{2}, x+w22<w1x + \frac{w_2}{2} < w_1, 0<y−h220 < y - \frac{h_2}{2}, and y+h22<h1y + \frac{h_2}{2} < h_1.

Input ends with a line of six numbers whose first value is 00; that line is not processed.

Output

For each test case, print a single line in the form

P%

where PP is the percentage of the open floor space that is hidden from the camera, with 0≤P≤1000 \le P \le 100. Print PP rounded to exactly one decimal digit.

Examples3

  1. Example 1

    Input
    100 100 10 10 50 50
    100.0 100.0 25 25 50.0 50
    0 0 0 0 0 0
    
    Expected output
    0.3%
    2.8%
    
  2. Example 2

    Input
    100 100 20 20 30 40
    0 0 0 0 0 0
    
    Expected output
    1.3%
    
  3. Example 3

    Input
    1000 1000 100 100 500 500
    0 0 0 0 0 0
    
    Expected output
    0.3%