please point out d mistake in logic (question :2 find d pair of indices i,j where a[i]*a[j]>a[i]+a[j]

#include <stdio.h>
int comb(int x);
int main()
{
int t,n,s,i,k,l;
int a[1000005];
scanf("%d",&t);
while(t–)
{
k=0,l=0,s=0;
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%d",&a[i]);
if(a[i]==0||a[i]==1)
k++;
if (a[i]==2)
{
l++;
}
}

       s=s+n*(n-1)/2-k*(n-1)+k*(k-1)/2;
       if(l>=2)
       s=s-l*(l-1)/2; 
       
        printf("%d\n",s );

       }
return 0;
}

There is no problem with your logic, but the only problem is your datatype.check your corrected solution in the following link. www.codechef.com/viewsolution/3934855.
just change int to long long int.

2 Likes

problem statement?

it is PROSUM