bzoj4036 [HAOI2015] Bitwise OR (probability and expectation + fmt)

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 k = 1 o o k ( p k [ U ] p k 1 [ U ] )
After the Mobius transform, simplify it and you get a sequence of proportional numbers, because p = 1 , So all but the last item are 0 1 1 p
Then quickly Mobius inversion can return. The answer is U's coefficient.
complexity O ( n 2 n )

#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;
}

Intelligent Recommendation

[BZOJ4036] [HAOI2015] bitwise OR

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...

BZOJ4036: [HAOI2015] bitwise OR

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...

HAOI2015 BZOJ4036 [] [] [] Luo Valley bitwise or P3175 (Min-Max capacity repellent) (the FMT)

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...

Bzoj4036 [HAOI2015] bitwise or FWT+min-max

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...

[BZOJ4036] Bitwise OR (HAOI2015)-Min-Max tolerance + FWT

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...

More Recommendation

HAOI2015 inclusion and exclusion [] [] [] FMT Bitwise or

【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...

P3175 [haoi2015] bit or (min - max surging, FMT, probability expectation, the whole network is the clearest inspection!)

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...

bzoj 4036: [HAOI2015] bitwise or FMT+expected dp

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...

[FMT][DP] BZOJ 4036: [HAOI2015] Bitwise OR

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 ...

BZOJ4036 [HAOI2015] minmax bitwise or {+ repellency desired receiving the FWT +]

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...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top