Tuesday, August 19, 2025

Lightoj 1178 solution in English

Lightoj 1178 : Problem Link







In this problem, we are given the lengths of the four sides of a trapezium. We need to calculate its area.

We know the formula for the area of a trapezium is:

Area=12×(sum of parallel sides)×(distance between them)\text{Area} = \tfrac{1}{2} \times (\text{sum of parallel sides}) \times (\text{distance between them})

That is:

Area=12×(a+c)×h\text{Area} = \tfrac{1}{2} \times (a + c) \times h

Here:

  • aa and cc are the lengths of the parallel sides.

  • hh is the height (perpendicular distance between aa and cc).

We are given aa and cc, but not hh. So, we need to calculate hh.


Step 1: Drop perpendiculars

  • From point CC, drop a perpendicular CPCP onto ABAB.

  • From point DD, drop a perpendicular DQDQ onto ABAB.

Thus:

CP=DQ=hCP = DQ = h

Also:

PQ=c,AP+BQ=acPQ = c, \quad AP + BQ = a - c

Let:

AP=x,BQ=acxAP = x, \quad BQ = a - c - x

Step 2: Apply Pythagoras

Now, consider right triangles APC and BDQ.

In triangle APC:

AC2=AP2+h2AC^2 = AP^2 + h^2 d2=x2+h2h2=d2x2...(1)d^2 = x^2 + h^2 \quad \Rightarrow \quad h^2 = d^2 - x^2 \quad ...(1)

In triangle BDQ:

BD2=BQ2+h2BD^2 = BQ^2 + h^2 b2=(acx)2+h2h2=b2(acx)2...(2)b^2 = (a - c - x)^2 + h^2 \quad \Rightarrow \quad h^2 = b^2 - (a - c - x)^2 \quad ...(2)

Step 3: Eliminate hh

From equations (1) and (2):

d2x2=b2(acx)2d^2 - x^2 = b^2 - (a - c - x)^2

Expanding:

d2x2=b2(a2+c2+x22ac2ax+2cx)d^2 - x^2 = b^2 - (a^2 + c^2 + x^2 - 2ac - 2ax + 2cx) d2x2=b2a2c2x2+2ac+2ax2cxd^2 - x^2 = b^2 - a^2 - c^2 - x^2 + 2ac + 2ax - 2cx d2=b2a2c2+2ac+2ax2cxd^2 = b^2 - a^2 - c^2 + 2ac + 2ax - 2cx 2ax2cx=d2b2+a2+c22ac2ax - 2cx = d^2 - b^2 + a^2 + c^2 - 2ac x=d2b2+a2+c22ac2a2cx = \frac{d^2 - b^2 + a^2 + c^2 - 2ac}{2a - 2c}

So we have found x.

Step 4: Solve for hh

Now substitute xx into equation (1):

h2=d2x2h^2 = d^2 - x^2 h=d2(d2b2+a2+c22ac2a2c)2h = \sqrt{d^2 - \left(\frac{d^2 - b^2 + a^2 + c^2 - 2ac}{2a - 2c}\right)^2}

Step 5: Area of the trapezium

Finally, substitute hh back into the trapezium formula:

Area=12×(a+c)×h\text{Area} = \tfrac{1}{2} \times (a + c) \times h

Now we have the formula to calculate the trapezium’s area using the four sides. 

Source Code : SourceCodeLink


Share:

0 comments: