What wrong in this code same Got accepted on codeforces but not here

#include
#include
#include
using namespace std;
typedef long double ll;

const int MAX=1e6+5;

ll last[MAX];
int a[MAX];
ll ans[MAX];

int main() {

long long n;	cin>>n;
memset(last,0,sizeof(last));
memset(ans,0,sizeof(ans));
for(int i=1;i<=n;i++)cin>>a[i];
ll sum=0.0;
for(int i=1;i<=n;i++)
{
	ans[i]=ans[i-1]+(i-last[a[i]]);
	last[a[i]]=i;
}

for(int i=1;i<=n;i++)
sum+=ans[i];

cout<<fixed<<setprecision(7);
sum=(2*sum-n)/(n*n);
cout<<sum;
return 0;

}

@yaduvanshii092 there are precession issue with doubles and float change setprecission(7) to 6 it works

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.