Getting Wrong answer in this question https://www.codechef.com/problems/RECTSQ

https://www.codechef.com/viewsolution/41793237

Above is the problem code
Here we need to find the minimum number of squares for an area of a rectangle and i have done like taking the minimum of length or breadth which is divisible and then printing it.
But no getting the correct answer.

there are solutions related to gcd please don’t suggest that.

Since you want to have minimum number of squares , you have to have largest square. So you need to find maximum factor (i.e gcd) and then simply (length/gcd)*(breadth/gcd) is your answer.

I don’t think there’s any other way. You have to use the concept of gcd.

If there’s another way I would love to know that.

1 Like

Yes he has done it wrong. When i give input 4 3 output is 3 which is wrong.Ans should be 12.