Timer is Running

Area of intersection of two circles
Submissions: 719   Accuracy:


  Difficulty: Easy   Marks: 2

You will be given the coordinates of the centres and the radii of two circles. Your task is to find the area of their intersection.

The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consists of one line. This line has six space separated integers denoting x1, y1, r1, x2, y2, r2 where (x1, y1) is the centre of the first circle and r1 is its radius and (x2, y2) is the centre of the second circle and r2 is its radius. 

Note: Use the value of Pi as 3.1415926535897932384


Corresponding to each test case, in a new line, print the greatest integer less than or equal to the area of intersection of the two circles. See floor function here.


1 ≤ T ≤ 100

-109x1, y1, x2, y2 ≤ 109       

1 ≤ r1, r2 ≤ 109



0 0 4 6 0 4
0 0 5 11 0 5
0 0 10 9 0 1




For the first case, the area of intersection comes out to be around 7.25298806, the greatest integer less than or equal to this is 7.
In the second case, there is no area common to the two given circles, hence the answer is 0.


** For More Input/Output Examples Use 'Expected Output' option **

Author: Hemang Sarkar

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.