5
1
And then the King said: You fought bravely, Knight, and your deed will not be forgotten for centuries. For your valor I grant you this castle and the lands around it. Things rush me, and I can not take you to the castle. Therefore, I will give you the way from this place to the castle. Now go and come back after the deadline. - as it is written in the Green Book of Years.
In addition, it is known from the Green Book of Years that the lands with which the castle was granted were in the shape of a circle. The king was very wise and, in order to avoid unnecessary proceedings regarding the right to land, always granted only areas of land on the map that have a convex shape.
Recently, historians have had information about where the castle was located and where this historical conversation took place. They want to know how much land did the Knight get on the assumption that the road to the castle was perfectly straight.
Explanation
The following figure shows in light gray the territory originally granted to the knight, and in dark gray, the one that came to him as a result of the king giving him the way.
Input
The first line of the input contains two floating-point numbers: xk and yk - the coordinates of the place where the dialogue took place. The second line contains three floating-point numbers: xc, yc and rc - the coordinates of the castle and the radius of the circle that bounds the land granted with it.
Output
Print one floating-point number - the area of the land obtained by the Knight, with an accuracy of at least three characters after the decimal point.
Tests
Input Output
2 5
5.69646
2 1 1
3 9
80.7130
2 3 5
1 3
3.141
1 2 1
Note: A triangle may not include the entire semicircle if it is too close to the center, as in the test I have given.
4
Hi there! Please consider using The Sandbox for your challenges. I've read this several times and I'm not sure what area we're supposed to find. The dark grey? The light grey? The sum of those regions?
– Giuseppe – 2019-08-23T13:53:55.5905
Please also avoid excessively long backstories. In this case, because the challenge refers back to the backstory, it actually hinders your challenge. :-(
– Giuseppe – 2019-08-23T13:55:16.513@Giuseppe The sum of those regions. – Ver Nick says Reinstate Monica – 2019-08-23T14:14:06.080
@Giuseppe A triangle may not include the entire semicircle if it is too close to the center (as in the test I have given). – Ver Nick says Reinstate Monica – 2019-08-23T14:19:48.460
1Can you please provide examples with a radius unequal to 1? – Jitse – 2019-08-23T14:51:53.713
Can you also please provide examples where the traveled distance lies within the circle? – Jitse – 2019-08-23T15:06:33.363
1Also, the triangle will never, ever include the entire semicircle, unless the radius is infinite, which it cannot be. – Jitse – 2019-08-23T15:08:28.750
4Why is the outcome of the third test case not
3.141
? – Joel – 2019-08-23T19:43:58.420Also, your challenge should be understandable if you deleted the backstory, as people normally skip the backstory – MilkyWay90 – 2019-08-24T00:57:51.847
@Joel Oh, I'm sorry, thanks for mentioning. – Ver Nick says Reinstate Monica – 2019-08-24T08:16:43.673
@MilkyWay90 I cut off unnecessary parts of the backstory, leaving only the needed ones. – Ver Nick says Reinstate Monica – 2019-08-24T08:22:20.810
A note about trying to use "real numbers" for input. It is not possible to have a program that can accept a real number, this is because there are more real numbers than there are finite binary strings. You likely mean something other than a real number and it would be good if you said what. It seems like most people have taken this to mean floats. – Post Rock Garf Hunter – 2019-08-24T13:06:08.737
I'm more worried about the "decimals". Are the last three values supposed to be integers? – G. Sliepen – 2019-08-24T13:07:48.580
1@G.Sliepen No. I edited to make it more clear. – Ver Nick says Reinstate Monica – 2019-08-24T13:26:28.457
@SriotchilismO'Zaic Edited. – Ver Nick says Reinstate Monica – 2019-08-24T13:26:40.387