Tuesday, August 19, 2025

Lightoj 1331 solution in English

 

Lightoj 1331 Ajent J 

Problem Link

Click here to see the discussion in Bangla

In the movie Dhoom 2, Hrithik Roshan’s diamond theft scene is quite famous. Similarly, LightOJ problem 1331 is about a diamond theft.

                                          


Here we have an agent ‘J’ who wants to steal the diamond kept in a museum. But the theft isn’t that easy, because there are three circular laser scanners, continuously rotating.

These three circles are placed in such a way that each circle is externally tangent to the other two, and the diamond is placed in the middle enclosed region.

Our task is to find the area of that enclosed region (the shaded diamond-shaped area). The radii of the three circles are given: R1,R2,R3R1, R2, R3.


                                     


Step 1: Forming the Triangle

If we connect the centers of the three circles, we form a triangle.

  • The distance between the centers of circle R1R1 and R2R2:

    a=R1+R2a = R1 + R2
  • The distance between the centers of circle R2R2 and R3R3:

    b=R2+R3b = R2 + R3
  • The distance between the centers of circle R1R1 and R3R3:

    c=R1+R3c = R1 + R3

Step 2: Area of the Triangle

Once we have the three sides a,b,ca, b, c, we can calculate the area of the triangle using Heron’s formula.

First compute the semi-perimeter:

s=a+b+c2s = \frac{a+b+c}{2}

Then, the triangle’s area is:

Area=s(sa)(sb)(sc)\text{Area}_{\triangle} = \sqrt{s(s-a)(s-b)(s-c)}

Step 3: Sector Areas (Circular Arcs)

                                              


From basic geometry, we know that the area of a circular sector is:

Sector Area=12r2θ\text{Sector Area} = \tfrac{1}{2} r^2 \theta

where rr is the circle’s radius and θ\theta is the angle in radians subtended at the circle’s center.

So, to compute the circular sectors inside the triangle, we need the angles of the triangle at the vertices.

Using the cosine rule:

cos(C)=a2+b2c22ab\cos(C) = \frac{a^2 + b^2 - c^2}{2ab} cos(A)=b2+c2a22bc\cos(A) = \frac{b^2 + c^2 - a^2}{2bc} cos(B)=c2+a2b22ca\cos(B) = \frac{c^2 + a^2 - b^2}{2ca}

Now, the sector areas are:

Area1=12R12arccos(c2+a2b22ca)\text{Area}_1 = \tfrac{1}{2} R1^2 \cdot \arccos\left(\frac{c^2 + a^2 - b^2}{2ca}\right) Area2=12R22arccos(b2+a2c22ab)\text{Area}_2 = \tfrac{1}{2} R2^2 \cdot \arccos\left(\frac{b^2 + a^2 - c^2}{2ab}\right) Area3=12R32arccos(c2+b2a22bc)\text{Area}_3 = \tfrac{1}{2} R3^2 \cdot \arccos\left(\frac{c^2 + b^2 - a^2}{2bc}\right)

Step 4: The Diamond Area

Finally, the required shaded region (diamond area) is:

Diamond Area=Area(Area1+Area2+Area3)
For source code: Source code




Share:

0 comments: