1 / 19
Aug 2013

This solution is a one-liner once you figure out the logic behind it.

I drew a bunch of grids on the graph paper on my desk, then I solved them. Then I messed up my code a few times, then I got AC.

If you're still drawing a blank, post back.

yeah i m still not able to solve,please explain the algo to solve it..

What would be your answer if N or M were 1? (Let's assume for the sake of our discussion that N <= M)

Correct. Now how about if N = 2?

Ex:

2
2 9
2 10

Draw these out on paper. Do you notice the pattern yet?

Post code using code tags.

  Thsi is code

This is wrong:

Removed code

for 2 9 it should be 9,and for 2 10 it should be 10..correct me if wrong???also can L shape be rotated and placed or it has to be like normal L??

It can be rotated.

You do not have the correct answer for both test cases.

Also, you will find that (10^8)^2 is a very big number.

Then what's the pattern i m not able to figure it out???Also plz can u give some more sample input output

I just gave you two test cases. You got one of them right. Work on the other one. Drawing it out on paper is useful.

I will not be just giving you the answer. I'm here to help you learn.

ok but plz tell me the output for 2 9 because according to me it should be 9 only...i drew it on paper and unless u cover one of the two rows completely there is always a L possible..so accrdng to me answer should be 9

Take a closer look at:

1
2 3

The answer for 2 9 is definitely not 9.

yeah i think i got the pattern thanks..will now try the code...

still getting WA at spoj...can u plz check these-
for 15 30 ans-225
16 5 - 32
8 50 - 200

my pattern is (m*(n/2))

i m doing minimum of((m*(n/2)),(n*(m/2))) but still getting WA..is this logic also wrong??????

Suggested Topics

Want to read more? Browse other topics in JAVA based languages or view latest topics.