Блог пользователя paramvi

Автор paramvi, 10 лет назад, По-английски

Hello guys. I need help in cracking a problem. I was trying to do this problem but my answer is coming out to be incorrect. Can you guys please help me in solving this problem.

My Solution.

Let's say number of tiles required at the end of the i-1'th iteration is tile_n. We will store how much area is left in the each of the "tile_n" tiles.

Now for i'th tile in the input, I will go through each of the "tile_n" tiles (stored) and will check if area of the any one of the "tile_n" tiles is greater than i'th tile.

if yes

Let's say it is the j'th tile.

I will check whether or not area of the j'th tile is a multiple of i'th tile. (this is so because we want to cut the proper tile from the j'th tile)

else

I will add another tile, tiles_n=tiles_n+1

and repeat.

Clearly my solution is lagging somewhere. Can please someone correct my algo. or explain me what to do in this problem.

  • Проголосовать: нравится
  • 0
  • Проголосовать: не нравится