1 / 6
Jun 2012

No one can see your code but you. Please post it in here using code tags.

If you're trying to declare an array of size 10^9 or trying to find all of the primes up to 10^9 then that is the reason. You will need to find a more efficient algorithm.

Thanks! I've got it, time limit is 6 sec. And my code isn't effective enough ) But the error SIGKILL is a little bit misleading.

using System;
namespace TaskSolving
{
    class PRIME1
    {
        static void Main(string[] args)
        {
            var cases = Int32.Parse(Console.ReadLine());
            for (int i = 0; i < cases; i++)
            {
                var edges = Console.ReadLine().Split(' ');
                var m = Int32.Parse(edges[0]);
                if (m <= 2)
                {
                    Console.WriteLine(2);
                    m = 3;
                }
                m += 1 - m % 2;
                var n = Int32.Parse(edges[1]);
                for (int p = m; p <= n; p += 2)
                {
                    if (isPrime(p))
                    {
                        Console.WriteLine(p);
                    }
                }
                Console.WriteLine();
            }
        }
        static bool isPrime(int n)
    {
        for (int i = 3; i <= Math.Sqrt(n); i += 2)
        {
            if (n % i == 0)
            {
                return false;
            }
        }
        return true;
    }
}
}

Unfortunately, due to the nature of C#, many TLE solutions will return SIGKILL instead. That is the case here.

9 months later
16 days later