ZOJ Problem Set - 2675
It is well known that mammoths used to live in caves. This is a story of a little mammoth who lived in a cave with his mummy and daddy.
The mammoth was little and very cute. And he was very curious. He used to peep out of the cave and look around. And one day mummy said him:
You are a big boy now, dear, so you may go out of the cave and take a little small walk around. But beware! There is a lot of danger outside. Horrible humans may try to catch you and make a dinner out of you! Do no walk further than r meters away from the cave entrance.
And the little mammoth made the first step out of the cave. He was a good boy, so he decided not to violate mummy's order. But suddenly he saw a nice field of grass around. Nice, green, juicy, tasty grass! How could he stand it!
But no, those dangerous humans. Little mammoth thought for a while and decided that he would only eat the grass that he can reach not breaking mummy's recommendation.
The field of grass is a rectangle. Find out how much grass can little mammoth eat.
There are several test cases in the input. The first line of each case contains xc , yc and r --- coordinates of the entrance to the cave and the distance little mammoth is allowed to walk from it.
Next line contains x1 , y1 , x2 , and y2 --- coordinates of two opposite corners of the grass field. Coordinate system is set up in such a way that field's sides are parallel to coordinate axes.
All numbers in the input file are integer and do not exceed 1000 by their absolute values, r > 0, both field sides are non-zero.There is an empty new line between each case.
OutputOutput the area of the part of the field where little mammoth can eat grass. Your answer must be accurate up to 10-6.
There should be an empty new line between each case.
Source: Andrew Stankevich's Contest #8