Division vs. addition

Revision en1, by whatthemomooofun1729, 2024-03-14 11:32:31

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?

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English whatthemomooofun1729 2024-03-14 11:32:31 589 Initial revision (published)