Vfk thesis title. For details, please refer to the 2015 Proceedings of the National Training Team Lu Kaifeng, "The Properties and Application of Set Power Series and Its Fast Algorithm"
This problem is to find the set and convolution, you can use the fast Mobius transform.
The answer is
After the Mobius transform, simplify it and you get a sequence of proportional numbers, because
, So all but the last item are 0
Then quickly Mobius inversion can return. The answer is U's coefficient.
complexity
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 25
#define eps 1e-7
inline int read(){
int x=0,f=1;char 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;
}
int n,bin[N];
double a[1100000];
int main(){
// freopen("a.in","r",stdin);
n=read();bin[0]=1;
for(int i=1;i<=n;++i) bin[i]=bin[i-1]<<1;
for(int i=0;i<bin[n];++i) scanf("%lf",&a[i]);
for(int i=0;i<n;++i)
for(int s=0;s<bin[n];++s)
if(s&bin[i]) a[s]+=a[s^bin[i]];
for(int i=0;i<bin[n];++i){
if(a[i]>1-eps){
if(i!=bin[n]-1){puts("INF");return 0;}
a[i]=0;continue;
}a[i]=1.0/(a[i]-1);
}for(int i=0;i<n;++i)
for(int s=0;s<bin[n];++s)
if(s&bin[i]) a[s]-=a[s^bin[i]];
printf("%.7lf\n",a[bin[n]-1]);
return 0;
}
Portal: Description At first you have a digital 0, every second you will randomly select a number from [0,2 ^ n-1], and with your hands or digital (c ++, c of |, pascal Of or) operation. Select a numb...
Questions on the vfk paper Remember U=2n−1 U = 2 n − 1 ,because ∀T⊆SU|T=U ∀ T ⊆ S U | T = U We regard p as a set power series, then there is ans=∑∞k=1k&lo...
BZOJ Portal Luo Gu Portal answer: First, with this bit about the expectations of the title it is clear that consideration Min-Max inclusion and exclusion. This question is obviously the set of all bin...
Description At the beginning you have a number 0, every second you will randomly select a number of [0, 2^n-1], or with the number in your hand or (c++, c |, pascal or) operation. The probability of s...
Test address:Bitwise or practice:This question requires Min-Max tolerance + FWT. Because it has always been or, if there is 1 1 ,This one 1 1 It will go on forever, then the question becomes, each tim...
【description】 first you have a number 0, you will each randomly select a second [ 0 , 2 n − 1 ] [0,2^n −1] [0,2n−1]Numbers, carry out or (C ++, C's |, Pascal's or) your hand with dig...
Algorithm template collection:ACM template Click I see the algorithm full bucket series! ! ! In fact, a new refining template integrated plan Weblink Problem Just starting you have a number 0 0 0, Eve...
Title At the beginning you have a number 0. Every second you will randomly select a number [0,2^n-1] and perform an OR (c++, c|, pascal or) operation with the number in your hand. The probability of c...
Description At first there was an empty set, and the full set was U 。 every time PT The probability of giving a set T , So that the collection he owns becomes his union with this collection. Asked to ...
Topic Link BZOJ4036 answer Good routine that ah ,,, We ask, in fact, is a collection of\(n\)More\(1\)Appeared in the latest\(1\)Expected time is clearly\(minmax\)Inclusion-exclusion \[E(max\{S\}) = \s...