This is the problem link https://www.hackerrank.com/contests/amrita-icpc-onsite-2013-practice/challenges/j

I am not getting its tutorial , How to solve this question , My solution is giving WA ,I solved it by placing in a particular position for which i thought it will give min area.

Solving this question requires a bit of imagination, or at least a pen and paper to try a few simple arrangements. I assume you are familiar with basic 2D geometry.

```
Area of a rectangle = length*breadth.
Height of an equilateral triangle = √3/2*side.
```

The required arrangement is as shown [here][1]. The algorithm is as follows.

```
let a and b be the inputs (sides of the two triangles)
if a < b
swap a and b
if b <= a/2
result = √3/2*a*a
else
result = √3/2*a*(a/2+b)
print result
```

Hope this helps!

[1]: http://pasteboard.co/YMyYOMw6.jpg

1 Like