whatthemomooofun1729's blog

By whatthemomooofun1729, history, 2 months ago, In English

Hi, I was just working on this problem, and I noticed that when I changed my operations from division to addition, it resulted in a huge time difference. With division, my code TLEs, while with addition, my code runs in 400ms (you can see where I changed the code on lines 136 and 142). Division is a more costly operation than addition, but why is it causing such a big difference in runtime? Should we avoid more costly operations to prevent TLE?

»
2 months ago, # |
  Vote: I like it 0 Vote: I do not like it

This Wikipedia article should answer the question and it also has some valuable information in a very compact form ! https://en.wikipedia.org/wiki/Computational_complexity_of_mathematical_operations