摘要:代 码 三 行

luogu3802小魔女帕琪

题面

zzq题目分享讲的题,代码真就三行…

而且又是ob鸽鸽的题呢.

题目分析

发现只要出现了一个$1$到$7$的排列,那么就会产生$1$的贡献,无论位置.

那么我们考虑求出一个位置上排列贡献的期望,这个位置上后$7$位产生一次姆q七重奏的期望是$\frac{a_1}{n} \times \frac{a_2}{n-1} \times \frac{a_3}{n-2} \times \frac{a_4}{n-3} \times \frac{a_5}{n-4} \times \frac{a_6}{n-5} \times \frac{a_7}{n-6} \times 7! \times 1$,应该很好理解.

然后根据期望的可加性,上式乘以$n-6$即得答案.

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "iostream"
#include "cstdlib"
#include "cstdio"
#include "cstring"
#include "cmath"
#include "cctype"
#include "ctime"
#include "iomanip"
#include "algorithm"
#include "set"
#include "queue"
#include "map"
#include "stack"
#include "deque"
#include "vector"
#define R register
#define INF 0x3f3f3f3f
#define debug(x) printf("debug:%lld\n",x)
#define debugi(x) printf("debug:%d\n",x)
#define debugf(x) printf("debug:%llf\n",x)
#define endl putchar('\n')
typedef long long lxl;
double pachy[7],n,n7=1;
inline lxl read()
{
char c(getchar());
lxl f(1),x(0);
for(;!isdigit(c);(c=='-')&&(f=-1),c=getchar());
for(;isdigit(c);x=(x<<1)+(x<<3)+(c^48),c=getchar());
return f*x;
}
int main(void)
{
for(R int i(0);i<7;++i)scanf("%lf",pachy+i),n+=pachy[i],n7*=(i+1);
printf("%.3lf\n",n7*pachy[0]/n*pachy[1]/(n-1)*pachy[2]/(n-2)*pachy[3]/(n-3)*pachy[4]/(n-4)*pachy[5]/(n-5)*pachy[6]);
return 0;
}