Run time error please help! perfectly works on gdb compiler

#include<stdio.h>

int main(void)
{
    long long int t,i,j,pair;
    scanf("%lld",&t);
    long long int n;
    while(t--)
    {
        pair=0;
        scanf("%lld",&n);
        long long int a[n];
        for(i=0;i<n;i++)
        {
            scanf("%lld",&a[i]);
        }
        for(i=0;i<=(n/2);i++)
        {
            for(j=i+1;j<n;j++)
            {
                if((a[i]+a[j])==(a[i]*a[j]))
                    pair++;
            }
        }
        printf("%lld \n",pair);
    }
    return 0;
}```

Please format your code - the forum software has mangled it and it won’t compile! :slight_smile:

1 Like

can u explain how to format it

@raghav_3018 Click the link that I gave.

1 Like

now tell me the error

Question link

Which RE ?

It’s TLE not RE.

3 Likes

If it’s this, which it seems to be, it’s a TLE, not an RE.

Edit:

Beaten XD

Edit2:

Maybe I should not include the whole “Format your Code” thing from now on, and just tell people to link to their solutions instead.

4 Likes

i m not sure
can you initialize i,j,pair inside while of t.

I think he should get TLE and not RE ?
Maybe :thinking::thinking::thinking:

@raghav_3018 I am very noob in C++. I generally use python. I think @ssjgz and @everule1 can help you. They are pro in C++ and super helpful.

Edit: they already help

The test cases are weak I think
try:

1
6
1 3 2 4 0 0

sorry guys and thnx for the help
and u r right ssjgz and shlok and everule

2 Likes

I beat you because this was a question from december challenge which i had given
I didn’t check the submission link

if((a[i]+a[j])==(a[i]*a[j]))
                    pair++;

This gave it away, and the code was O(n^2)

1 Like