Title:
There is an n-sided die, the i-th face has the value a(i),
and m faces have a color.
Now roll the dice once, the score += the value
of the face that was cast . If you cast the dice on the colored face, you can roll it again to
find the desired score.
Data range: n<=200, m<=n, 0<=a(i)<=200,
solution:
n grids, m grids with color, set the weight of the color to be x, and the weight of no color to be y, then E = (xm + E) ∗ mn + yn − m ∗ n − mn The term is: E = x + yn − m = sum {a [i]} n − mn grids, m grids with color, \\ with color grid weight sum as x, no color weight sum Is y,\\ then E=(\frac{x}{m}+E)*\frac{m}{n}+\frac{y}{nm}*\frac{nm}{n}\\ shift Item: \\ E=\frac{x+y}{nm}=\frac{sum\{a[i]\}}{nm} n a grid sub , with a color color of grid sub- m th ,Is provided with a color color of grid sub- weight value and to X ,No color color of right values and to the y- ,That it E=(mx+E)∗nm+n−mand∗nn−mMove items have:E=n−mx+and=n−msum{ a[i]}
code:
#include <bits/stdc++.h>
using namespace std;
signed main(){
int n,m;
while(scanf("%d",&n)!=EOF){
double sum=0;
for(int i=1;i<=n;i++){
int x;scanf("%d",&x);
sum+=x;
}
scanf("%d",&m);
for(int i=1;i<=m;i++){
int x;scanf("%d",&x);
}
//要先判sum==0,然后判m==n.
if(sum==0){
puts("0.00");
continue;
}
if(m==n){
puts("inf");
continue;
}
//
double ans=sum*1.0/(n-m);
printf("%.2f\n",ans);
}
return 0;
}