1 / 6
Jan 2023

I’m getting WA for PRIME118 in C++. Everything seems right to me but there is probably an edge case I’ve missed. Anyone knows what’s the problem?

Got AC
  • created

    Jan '23
  • last reply

    Jan '23
  • 5

    replies

  • 551

    views

  • 2

    users

  • 1

    link

You should test it with the example data given in the problem.

I’ve tested your code with some random ranges, but I haven’t been able to find any differences from the answers given by my AC code.

So apparently it was an off by one error. The limits of the segmented sieve were set wrong so they skipped a number when m - n > 32000. Anyway, got AC now

Ah good catch. I couldn’t try any big ranges as the amount of output is limited on ideone.

Please could you edit your posts to remove the code? Stop people copying and submitting it.