标签:
题目链接:
Time Limit: 4000/2000 MS (Java/Others)
Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 105 Accepted Submission(s): 75
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
int a[600];
int main()
{
int t,n,k;
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(int i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
double ans=0;
for(int i=0;i<n;i++)
{
for(int j=0;j<n;j++)
{
if(i!=j)
{
if(a[j]<a[i])
ans+=1/(n*(n-1)*1.0);
}
}
}
printf("%.6lf\n",ans);
}
return 0;
}
标签:
原文地址:http://www.cnblogs.com/zhangchengc919/p/5296602.html