Friday, October 3, 2014

Tiles of Tetris, Not!


Problem

Tags : GCD , LCM

Idea : Given the height H and width W of a tiles . You have to find out the minimum number of tiles to make a square .

If H and W are equal , we can make a square by one tiles .

If H is greater than W , then

                 - If W is a divisor of H ,  then we can make a square by H/W tiles .
                 - Else we  can make a square by lcm ( W , H ) tiles .

If W is greater than H , then

                 -If H is a divisor of W ,  then we make a square by W/H tiles .
                 - Else we  can make a square by lcm ( W , H ) tiles .  

My Solution



No comments:

Post a Comment