Count triples of wall pillars that form a triangle none of whose sides crosses the square pedestal.
Medium6GeometryCombinatoricsBrute forceNo attempts yetTime limit2sMemory limit256 MBA new wing of a national museum in Amsterdam holds an exhibition of world treasures. The wing is built from rectangular rooms. Each room holds exactly one treasure, and every treasure rests on a square pedestal that is surrounded by glass and wood.
The curator is worried that a treasure will be stolen from the new wing, so he installs as many distinct security systems as possible in every room. One security system is three identical parts. Each part sends out one infrared laser beam and has two receivers for the beams sent out by the other two parts. The system works when the three parts are placed so that the beams form a triangle, and no beam of that triangle may be obstructed by the pedestal. Two security systems in the same room that form the same triangle are not distinct. Three parts on one straight line do not form a triangle.
The parts can only be installed on the pillars that stand against the walls of the room. There is one pillar for every meter of wall, and there is also one pillar in each corner of the room.

Figure 1: a room with a length and a width of 1 meter. The square in the top right corner of the room is the pedestal. The dots are the pillars that carry the security system parts, and the dashed lines are the infrared laser beams the parts send out. The pedestal blocks the beam between the bottom left pillar and the top right pillar, so only 2 of the 4 possible distinct security systems fit in this room.

Figure 2: a treasure room with a length and a width of 2 meters. 13 distinct security systems fit in this room.
The curator wants to know the largest number of distinct security systems that can be installed in each room of the new wing.
For this problem the pillars are points, any number of parts may sit on a single pillar, and height does not matter.
Given the length and the width of a room together with the position and the side length of the treasure pedestal, find the largest number of security systems that can be installed in that room.
The first line has one integer T, the number of test cases (1≤T≤20). Each test case is two lines.
The first line has two space separated integers L and W (1≤L≤100, 1≤W≤100), the length and the width of the room in meters.
The second line has three space separated real numbers X, Y and Ws, all in meters: the x coordinate, the y coordinate and the side length of the square pedestal. X and Y give the top left corner of the pedestal, and (x=0,y=0) is the top left corner of the room. The x axis runs along the length L and the y axis runs along the width W.
The pedestal always fits inside the room and never touches a wall, so X≥0.01, Y≥0.01, Ws≥0.01, X+Ws+0.01≤L and Y+Ws+0.01≤W. The distance from each corner of the pedestal to any line through two pillars is at least 0.0001 meters.
For each test case, print one line with a single integer: the largest number of security systems that can be installed in the room.