1 / 3
May 2023

I am having a time limit exceeded error in my code. I need some help regarding this

  • created

    May '23
  • last reply

    May '23
  • 2

    replies

  • 486

    views

  • 3

    users

In C++, I apparently made my code run faster by using sqrt() instead of floor() and not defining any functions, maybe that could work for you. Also remember no new line after the last test case. By the way I didn’t use Eratosthenes sieve or segmented sieve or something, it’s possible to do this with only just for loops and if statements.

What algorithm are you using?

Miller-Rabin worked for me.