Sunday, 14 January 2018

1A-THEATRE SQUARE by Petr

1A-THEATRE  SQUARE

My approach got "TLE" coz i used two loops which ranges upto 10^9.(But i donno how many test cases will it pass if i wont get "TLE" :p
Then after having a glance at Petr's code(just saw he used a formula - donno what at that time ;) ),
So i too tried to solve/to find a formula.
I came up with this : 
ceil(n/a)*ceil(m/a)
which is not true - it failed in a test case

but finally solved it using the same formula and it turns out that i failed coz of precision 


Test: #16, time: 15 ms., memory: 1812 KB, exit code: 0, checker exit code: 1, verdict: WRONG_ANSWER

Checker Log
wrong answer 1st numbers differ - expected: '4', found: '1'





But Petr solved this in constant time by using simple formula :
                  ((n + a - 1) / a) * ((m + a - 1) / a)

I missed a-1 in both numerators :(

No comments:

Post a Comment