Wannafly挑战赛14F 细胞

S o u r c e : Wannafly挑战赛14
P r o b l e m :

t m , a n s i = k = 0 + 2 k C ( t , k ) [ k mod 2 m == i ]

s u m = i = 0 2 m 1 a n s i 2222303 i mod 998244353

I d e a :
f ( x ) = i = 0 2 m 1 a n s i x i mod P , n = 2 m , w n n g P 1 1 ( mod P )

a n s i f ( w n j ) = ( 2 w n j + 1 ) t

w n 0 . . . w n n 1 f , I D F T a n s i

C o d e :

#include<bits/stdc++.h>
using namespace std;

#define lc o<<1
#define rc o<<1|1
#define fi first
#define se second
#define pb push_back
#define ALL(X) (X).begin(), (X).end()
#define bcnt(X) __builtin_popcountll(X)
#define CLR(A, X) memset(A, X, sizeof(A))
#define DEBUG printf("Passing [%s] in Line %d\n",__FUNCTION__,__LINE__)

using DB = double;
using LL = long long;
using PII = pair<int, int>;
const int N = 1<<20;
const LL MOD = 998244353;
//const int INF = 0x3f3f3f3f;
//const DB eps = 1e-8;
const int g = 3;

LL qpow(LL a, LL b) {
    LL ret = 1; a %= MOD;
    while(b) {
        if(b&1) ret = ret*a%MOD;
        a = a*a%MOD; b >>= 1;
    }
    return ret;
}
void rader(LL *y, int len) {
    for(int i = 1, j = len/2; i < len - 1; i++) {
        if(i < j) swap(y[i], y[j]);
        int k = len / 2;
        while(j >= k) j -= k, k /= 2;
        if(j < k) j += k;
    }
}
void NTT(LL *y, int len, int on) {
    rader(y, len);
    for(int h = 2; h <= len; h <<= 1) {
        LL wn = qpow(g, (MOD-1)/h);
        if(on == -1) wn = qpow(wn, MOD-2);
        for(int j = 0; j < len; j += h) {
            LL w = 1;
            for(int k = j; k < j+h/2; k++) {
                LL u = y[k];
                LL t = w * y[k+h/2]%MOD;
                y[k] = (u+t)%MOD;
                y[k+h/2] = (u-t+MOD)%MOD;
                w = w*wn%MOD;
            }
        }
    }
    if(on == -1) {
        LL t = qpow(len, MOD-2);
        for(int i = 0; i < len; i++)
            y[i] = y[i]*t%MOD;
    }
}

LL a[N];

int main() {
    LL n, m;
    scanf("%lld%lld", &n, &m);
    m = 1<<m;
    LL w = 1, wn = qpow(g, (MOD-1)/m);
    for(int i = 0; i < m; i++) {
        a[i] = qpow(2*w+1, n)%MOD;
        w = w*wn%MOD;
    }

    NTT(a, m, -1);
    LL ans = 0, tmp = 1;
    for(int i = 0; i < m; i++) {
        (ans += a[i]*tmp%MOD) %= MOD;
        tmp = (tmp*2222303)%MOD;
    }
    printf("%lld\n", ans);
    return 0;
}

猜你喜欢

转载自blog.csdn.net/qq_32506797/article/details/81096617