Primes 2

View as PDF

Submit solution

Points: 15 (partial)
Time limit: 3.0s
Memory limit: 32M

Problem type

Given two integers N and M (N \le M), output all the prime numbers between N and M inclusive, one per line.

N and M will be positive integers less than or equal to 1\,000\,000\,000.
The difference between N and M will be less than or equal to 5\,000\,000.

Sample Input

5 20

Sample Output

5
7
11
13
17
19

Comments


  • -2
    dchoo333  commented on Oct. 4, 2024, 11:09 a.m.

    Could someone please help with my submission (MLEing last two test cases). https://dmoj.ca/submission/6648597

    I've tried breaking it up into smaller sized segments, and my array for primes should be about 31622 items long max. Is this too much? Thanks very much.


  • -3
    PhoenixCoolIce  commented on April 22, 2024, 9:30 p.m.

    tle 😭


  • -1
    lwale1  commented on March 31, 2022, 6:46 p.m.

    I'm getting a segmentation fault on the last test case. Can someone have a look at my code please?


    • -1
      fbain1  commented on April 7, 2022, 1:28 a.m.

      You're running out of memory. You allocate an array that's M long, which will be <= 1,000,000,001. Assuming the largest possible value, that's 1,000,000,001 bools * 1 bytes per bool which equals 1000Mb. Obviously the problem limit is 32Mb, so it fails.