Help me in AOCC19 problem. I think problem is with setting precision but I don't know exactly

My issue

My code

// Update the code below to solve the problem

#include <bits/stdc++.h>
using namespace std;

int main() 
{
	int t;
    cin >> t;
	
	while(t--)
	{
	    int N, A, B;
	    cin >> N >>A >> B;
	    int a[N];
	    for(int i=0; i<N; i++)
	        cin>>a[i];
	    double x=1, y=1;
	    for(int i=0; i<N; i++)
	    {
	        if(a[i]!=A) x++;
	        if(a[i]!=B) y++;
	    }
	    double p=1/(x*y);
	    cout<<setprecision(10)<<p<<endl;
	}
}

Learning course: Solve Programming problems using C++
Problem Link: CodeChef: Practical coding for everyone

@shibamma
u are mistaking in calculation of probability
i have corrected it

include <bits/stdc++.h>
using namespace std;

int main()
{
int t;
cin >> t;

while(t--)
{
    int N, A, B;
    cin >> N >>A >> B;
    int a[N];
    for(int i=0; i<N; i++)
        cin>>a[i];
    double x=0, y=0;
    for(int i=0; i<N; i++)
    {
        if(a[i]==A) x++;
        if(a[i]==B) y++;
    }
    double p=(x*y)/(N*N);
    cout<<setprecision(10)<<p<<endl;
}

}

1 Like