Comments

This is another example of breaking the code with higher optimization when the code is not completely correct, Nicely explained as well. http://stackoverflow.com/questions/36626810/g-optimization-breaks-for-loops

On matrixSharif AIChallenge, 10 years ago
0

Are inter-college teams allowed? Or all the team members must be from the same institute?

The paste link is expired. Please provide the new link.

Can someone please explain H a little deeper (**Pencil Game**). I found the factors of L in O(sqrt(L)) and then iterated over them as:

bool ans = 0;
for(int i = 0; i < factors.size(); i++)
{
    w = factors[i];
    if(w>n)continue;
    for(int j = 0; j < factors.size(); j++)
    {
        h = factors[j];
        if(h>m)break;
        if(((2*l) % (w*h) != 0)) continue;
        k = (2*l)/(w*h) &mdash; (h-1)*n &mdash; (w-1);
        if(k&1)continue;
        k = k/2;
        u = k/n;
        x = k%n;
        if(u + h <= m && x + w <= n)
        {
            area = min(area, w*h);
            ans = 1;
        }
    }
}

After this, I check if ans = 1, then I print area, otherwise I print -1. I am getting TLE on test 2. Please guide me.