AT_abc392_d 题解
getchar_unlocked · · 题解
题目传送门
思路
可以使用枚举解决此题。
先将每一个骰子记在
然后枚举每一对骰子,
最终将所有的概率和
时间复杂度
AC CODE
#include<bits/stdc++.h>
using namespace std;
#define int long long
int read(){int x=0;char f=1,ch=getchar();while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();return x*f;}
const int N=105,E=1e5;
vector<int>vc[N];
int k[N],cnt[N][E+10];
signed main(){
int n=read();
for(int i=0;i<n;++i){
k[i]=read();
for(int j=0;j<k[i];++j){
int x=read();
vc[i].push_back(x);
++cnt[i][x];
}
}
double ans=0;
for(int i=0;i<n;++i)
for(int j=i+1;j<n;++j){
double sum=0;
for(int x=1;x<=E;++x)
if(cnt[i][x]>0&&cnt[j][x]>0)
sum+=cnt[i][x]*1.0/k[i]*cnt[j][x]/k[j];
ans=max(ans,sum);
}
printf("%.12lf\n",ans);
return 0;
}