2017NOIP模拟赛三 A酱的体育课-LMLPHP

2017NOIP模拟赛三 A酱的体育课-LMLPHP


据说改编自$CodeM 美团点评编程大赛初赛A 轮$

简单的水题。。。考试的时候没想到,xjb打了暴力。

显然,第$x$个人排在第$y$个位置的情况总数为$(n-1)!$,在这些情况中,第$x$人对答案的贡献是相同的,记为$p_{x,y}$。

总的情况数是$n!$,故答案为$$\frac{\sum p_{x,y}}{n}$$

看起来挺水的,结论出来逆元组合数什么的都不用求打上去就好了。

代码:

 #include<cstring>
#include<cmath>
#include<cstdio>
#include<algorithm>
#define foru(i,x,y) for(int i=x;i<=y;i++)
using namespace std; const int N=1e6+;
double v,u,c[N],d[N],ans;
int n;
int main(){
freopen("pe.in","r",stdin);freopen("pe.out","w",stdout);
scanf("%d%lf%lf",&n,&v,&u);
foru(i,,n)scanf("%lf",c+i);
foru(i,,n)scanf("%lf",d+i);
foru(i,,n){
foru(k,,n){
double j=n-k+;
ans+=u*n/(c[i]-(j-)*d[i]-v);
}
}
printf("%.3lf",ans/n);
return ;
}
05-23 06:45