# 4307 eve

Title Description

answer

Good question ah cents

Consider setting the number of intersection is at least the size of $ X $ $ a_x $, the $ a_x = (_ x ^ n) (2 ^ {2 ^ {nx}} - 1) $

Then we consider the inclusion and exclusion configured coefficients $ f_x $, so $ ans = \ sum_ {x = 0} ^ nf_xa_x $

Then we take into account if the intersection size exactly $ x $ ultimately to be counted $ [x \% 4 = 0] $ times, while for $ \ le x $ of $ i $, which for $ x $ contribution was $ (_i ^ x) $, so we need that $ [x \% 4 = 0] = \ sum_ {k = 0} ^ x (_k ^ x) f_x $

Consider binomial inversion, into the expression $ f_x = \ sum_ {k = 0} ^ x (-1) ^ {xk} (_ k ^ x) [x \% 4 = 0] $

Consider the $ [x \% 4 = 0] $-opening, this time we will use a very wonderful thing: the unit complex roots

Note $ w_m $ a front $ m $ th Root, then depending on the nature, we can get $ [x \% m = 0] = \ sum_ {i = 0} ^ {m-1} (w_m ^ x) ^ i $

于是 $f_x=\sum_{k=0}^x(-1)^{x-k}(_k^x)\sum_{i=0}^{4-1}(w_4^x)^i$

The $ I $ in advance, to give $ f_x = \ frac {(- 1) ^ x} {4} \ sum_ {i = 0} ^ {3} (1-w_4 ^ i) ^ x $

So we can $ O (nm) $ handle a $ f_x $, and then calculate the answer

Code

#include <bits/stdc++.h>
using namespace std;
const int N=1e7+5,P=998244353;
int n,jc[N],ny[N],w[4],W[4],f[N],s=1;
int X(int x){return x>=P?x-P:x;}
int C(int x,int y){
    return 1ll*jc[x]*ny[y]%P*ny[x-y]%P;
}
int K(int x,int y){
    int z=1;
    for (;y;y>>=1,x=1ll*x*x%P)
        if (y&1) z=1ll*z*x%P;
    return z;
}
int main () {
    cin>>n;jc[0]=1;
    for (int i=1;i<=n;i++)
        jc[i]=1ll*i*jc[i-1]%P;
    ny[n]=K(jc[n],P-2);
    for (int i=n;i;i--)
        [i - 1 ] = 1ll * i * [i]% P;
    w[0]=1;w[1]=911660635;
    for (int i=2;i<4;i++)
        w[i]=1ll*w[i-1]*w[1]%P;
    for (int i=0;i<4;i++)
        W[i]=1,w[i]=X(1+P-w[i]);
    for (int i=0,F=1;i<=n;i++,F=P-F){
        for (int j=0;j<4;j++)
            f[i]=X(f[i]+W[j]);
        f[i]=748683265ll*F%P*f[i]%P;
        for (int j=0;j<4;j++)
            W[j]=1ll*W[j]*w[j]%P;
    }
    for (int i=n,v=2,u;~i;i--)
        u=1ll*C(n,i)*X(v-1+P)%P,
        s=X(s+1ll*u*f[i]%P),v=1ll*v*v%P;
    cout<<s<<endl;return 0;
}

 

Guess you like

Origin www.cnblogs.com/xjqxjq/p/12285481.html