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

Автор Parvej, история, 2 года назад, По-английски

Today I was solving this problem.

I made two similar submissions.

Sub1 used class ( TLE ).

Sub2 exact same code without class ( AC ).

I can't understand why making the functions and variables as class's member consuming so much time?

I have googled but didn't find anything written about it.

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

»
2 года назад, # |
  Проголосовать: нравится +6 Проголосовать: не нравится

Have you tried to benchmark the programs locally against each other and figure out exactly what slows down the execution?

»
2 года назад, # |
  Проголосовать: нравится +24 Проголосовать: не нравится

Your mod variable changes from a constant to a variable and compilers are very good at optimizing constant modulus / division operations whereas variable ones are slow.