\(\mathcal{Description}\)

  Link.

  给定 \(n\) 和 \(m\) 次多项式 \(f(x)\),求

\[\sum_{i=0}^n\binom{n}{i}f(i)\bmod998244353
\]

  \(m\le10^5\),\(m\le n\le 10^9\)。

\(\mathcal{Solution}\)

  推式子叭~

\[\begin{aligned}
\sum_{i=0}^n\binom{n}{i}f(i)&=\sum_{i=0}^ma_i\sum_{j=0}^n\binom{n}{i}j^i\\
&=\sum_{i=0}^ma_ii![x^i]\left(\sum_{j=0}^{+\infty}\frac{x^j}{j!}\sum_{k=0}^n\binom{n}{k}k^j\right)\\
&=\sum_{i=0}^ma_ii![x^i]\left(\sum_{k=0}^n\binom{n}{k}e^{kx}\right)\\
&=\sum_{i=0}^ma_ii![x^i](e^x+1)^n
\end{aligned}
\]

多项式全家桶算出 \((e^x+1)^n\) 即可,复杂度 \(\mathcal O(m\log m)\)。

\(\mathcal{Code}\)

/*~Rainybunny~*/

#include <cmath>
#include <cstdio>
#include <algorithm> #define rep( i, l, r ) for ( int i = l, rpbound##i = r; i <= rpbound##i; ++i )
#define per( i, r, l ) for ( int i = r, rpbound##i = l; i >= rpbound##i; --i ) const int MOD = 998244353, MAXL = 1 << 18, MAXM = 1e5, INV2 = MOD + 1 >> 1;
int n, m, c[MAXM + 5], fac[MAXL + 5], ifac[MAXL + 5];
int F[MAXL + 5], G[MAXL + 5]; inline int sub( int a, const int b ) { return ( a -= b ) < 0 ? a + MOD : a; }
inline int mul( const long long a, const int b ) { return int( a * b % MOD ); }
inline int add( int a, const int b ) { return ( a += b ) < MOD ? a : a - MOD; }
inline int mpow( int a, int b ) {
int ret = 1;
for ( ; b; a = mul( a, a ), b >>= 1 ) ret = mul( ret, b & 1 ? a : 1 );
return ret;
} inline void init( const int len ) {
fac[0] = 1;
rep ( i, 1, len ) fac[i] = mul( i, fac[i - 1] );
ifac[len] = mpow( fac[len], MOD - 2 );
per ( i, len - 1, 0 ) ifac[i] = mul( i + 1, ifac[i + 1] );
} namespace PolyOper { const int MG = 3;
int inv[MAXL + 5], omega[19][MAXL + 5]; inline void init() {
inv[1] = 1;
rep ( i, 2, MAXL ) inv[i] = mul( MOD - MOD / i, inv[MOD % i] );
rep ( i, 0, 18 ) {
int* oi = omega[i];
oi[0] = 1;
int& o1 = oi[1] = mpow ( MG, MOD - 1 >> i >> 1 );
rep ( j, 2, ( 1 << i ) - 1 ) oi[j] = mul( oi[j - 1], o1 );
}
} inline void ntt( const int n, int* u, const int type ) {
static int rev[MAXL + 5];
int lgn = 1;
for ( ; 1 << lgn < n; ++lgn );
rep ( i, 1, n - 1 ) rev[i] = rev[i >> 1] >> 1 | ( i & 1 ) << lgn >> 1;
rep ( i, 1, n - 1 ) if ( i < rev[i] ) {
u[i] ^= u[rev[i]] ^= u[i] ^= u[rev[i]];
}
for ( int i = 0, stp = 1; stp < n; ++i, stp <<= 1 ) {
const int* oi = omega[i];
for ( int j = 0; j < n; j += stp << 1 ) {
rep ( k, j, j + stp - 1 ) {
int ev = u[k], ov = mul( oi[k - j], u[k + stp] );
u[k] = add( ev, ov ), u[k + stp] = sub( ev, ov );
}
}
}
if ( type == -1 ) {
for ( int invn = MOD - ( MOD - 1 ) / n, i = 0; i < n; ++i ) {
u[i] = mul( u[i], invn );
}
std::reverse( u + 1, u + n );
}
} inline void polyDir ( const int n, const int* u, int* w ) {
rep ( i, 1, n - 1 ) w[i - 1] = mul( i, u[i] );
w[n - 1] = 0;
} inline void polyInt( const int n, const int* u, int* w ) {
per ( i, n - 1, 0 ) w[i + 1] = mul( inv[i + 1], u[i] );
w[0] = 0;
} inline void polyInv( const int n, const int* u, int* w ) {
static int tmp[2][MAXL + 5];
if ( n == 1 ) return void( w[0] = mpow( u[0], MOD - 2 ) );
polyInv( n >> 1, u, w );
rep ( i, 0, n - 1 ) tmp[0][i] = u[i], tmp[1][i] = w[i];
ntt( n << 1, tmp[0], 1 ), ntt( n << 1, tmp[1], 1 );
rep ( i, 0, ( n << 1 ) - 1 ) {
tmp[0][i] = mul( mul( tmp[0][i], tmp[1][i] ), tmp[1][i] );
}
ntt( n << 1, tmp[0], -1 );
rep ( i, 0, n - 1 ) w[i] = sub( mul( 2, w[i] ), tmp[0][i] );
rep ( i, 0, ( n << 1 ) - 1 ) tmp[0][i] = tmp[1][i] = 0;
} inline void polyLn( const int n, const int* u, int* w ) {
static int tmp[2][MAXL + 5];
polyDir( n, u, tmp[0] ), polyInv( n, u, tmp[1] );
ntt( n << 1, tmp[0], 1 ), ntt( n << 1, tmp[1], 1 );
rep ( i, 0, ( n << 1 ) - 1 ) tmp[0][i] = mul( tmp[0][i], tmp[1][i] );
ntt( n << 1, tmp[0], -1 ), polyInt( n << 1, tmp[0], w );
rep ( i, 0, ( n << 1 ) - 1 ) tmp[0][i] = tmp[1][i] = 0;
} inline void polyExp ( const int n, const int* u, int* w ) {
static int tmp[MAXL + 5];
if ( n == 1 ) return void( w[0] = 1 );
polyExp( n >> 1, u, w ), polyLn( n, w, tmp );
tmp[0] = sub( add( u[0], 1 ), tmp[0] );
rep ( i, 1, n - 1 ) tmp[i] = sub( u[i], tmp[i] );
ntt( n << 1, tmp, 1 ), ntt( n << 1, w, 1 );
rep ( i, 0, ( n << 1 ) - 1 ) w[i] = mul( w[i], tmp[i] );
ntt( n << 1, w, -1 );
rep ( i, n, ( n << 1 ) - 1 ) w[i] = tmp[i] = 0;
} } // namespace PolyOper. int main () {
freopen( "number.in", "r", stdin );
freopen( "number.out", "w", stdout ); PolyOper::init();
scanf( "%d %d", &n, &m ), ++m;
rep ( i, 0, m - 1 ) scanf( "%d", &c[i] ); int len = 1;
for ( ; len < m; len <<= 1 );
init( len ), F[0] = 1;
rep ( i, 1, len - 1 ) F[i] = mul( ifac[i], INV2 ); PolyOper::polyLn( len, F, G );
rep ( i, 0, len - 1 ) G[i] = mul( G[i], n ), F[i] = 0;
PolyOper::polyExp( len, G, F ); int ans = 0;
rep ( i, 0, m - 1 ) ans = add( ans, mul( c[i], mul( fac[i], F[i] ) ) );
printf( "%d\n", mul( ans, mpow( 2, n ) ) );
return 0;
}

Solution -「多校联训」查拉图斯特拉如是说的更多相关文章

  1. Solution -「多校联训」数学考试

    \(\mathcal{Description}\)   Link.   给定 \(n\) 个函数,第 \(i\) 个有 \(f_i(x)=a_ix^3+b_ix^2+cx_i+d~(x\in[l_i, ...

  2. Solution -「多校联训」排水系统

    \(\mathcal{Description}\)   Link.   在 NOIP 2020 A 的基础上,每条边赋权值 \(a_i\),随机恰好一条边断掉,第 \(i\) 条段的概率正比于 \(a ...

  3. Solution -「多校联训」I Love Random

    \(\mathcal{Description}\)   给定排列 \(\{p_n\}\),可以在其上进行若干次操作,每次选取 \([l,r]\),把其中所有元素变为原区间最小值,求能够得到的所有不同序 ...

  4. Solution -「多校联训」签到题

    \(\mathcal{Description}\)   Link.   给定二分图 \(G=(X\cup Y,E)\),求对于边的一个染色 \(f:E\rightarrow\{1,2,\dots,c\ ...

  5. Solution -「多校联训」朝鲜时蔬

    \(\mathcal{Description}\)   Link.   破案了,朝鲜时蔬 = 超现实树!(指写得像那什么一样的题面.   对于整数集 \(X\),定义其 好子集 为满足 \(Y\sub ...

  6. Solution -「多校联训」消失的运算符

    \(\mathcal{Description}\)   Link.   给定长度为 \(n\) 的合法表达式序列 \(s\),其中数字仅有一位正数,运算符仅有 - 作为占位.求将其中恰好 \(k\) ...

  7. Solution -「多校联训」假人

    \(\mathcal{Description}\)   Link.   一种物品有 长度 和 权值 两种属性,现给定 \(n\) 组物品,第 \(i\) 组有 \(k_i\) 个,分别为 \((1,a ...

  8. Solution -「多校联训」古老的序列问题

    \(\mathcal{Description}\)   Link.   给定序列 \(\{a_n\}\),和 \(q\) 次形如 \([L,R]\) 的询问,每次回答 \[\sum_{[l,r]\su ...

  9. Solution -「多校联训」Sample

    \(\mathcal{Description}\)   Link   (稍作简化:)对于变量 \(p_{1..n}\),满足 \(p_i\in[0,1],~\sum p_i=1\) 时,求 \(\ma ...

随机推荐

  1. vue中自定义属性

    <div v-bind:id="name"></div> //v-bind:id="变量" or :id="变量"

  2. Git创建分支进行开发

    一.业务场景 自己当前开发的项目算是一个中型项目,整个项目都是由自己一个人开发完成,主要有两个子项目,一个是小程序的后台,一个是小程序的后台管理系统. 因为从一开始就只有我一个人在进行开发,所以自己平 ...

  3. Pop Sequeue

    题目描述 Given a stack which can keep M numbers at most. Push N numbers in the order of 1,2,3...,N and p ...

  4. class、抽象类、接口区别

    Java 抽象类 在面向对象的概念中,所有的对象都是通过类来描绘的,但是反过来,并不是所有的类都是用来描绘对象的,如果一个类中没有包含足够的信息来描绘一个具体的对象,这样的类就是抽象类. 由于抽象类不 ...

  5. MicroPython 8266 配置

    MicroPython 8266 配置 刷固件 下载固件 MicroPython - Python for microcontrollers 从以上网址下载固件,本文下载的是esp8266-20210 ...

  6. day3 创建数组并完成对数组的操作

    1.实现函数action()初始化数据全0的操作 2.实现函数assignment()利用指针给数组赋值0~9 3.实现函数print()打印数组的每个函数 4.实现函数reverse()完成对数组的 ...

  7. 【刷题-LeetCode】289. Game of Life

    Game of Life According to the Wikipedia's article: "The Game of Life, also known simply as Life ...

  8. linux下编译支持opencl的opencv for android

    主要的步骤其他人已经写过,请参考这篇:https://www.cnblogs.com/hrlnw/p/4720977.html 操作的细节请参考附件的pdf:  https://files.cnblo ...

  9. 保存网页到zotero研究

    打印长页 打印长页很麻烦,打印加载时间过长,打印后无法选取文字 https://www.zhihu.com/question/52639201?sort=created 插件 浏览器自带直接网页打印p ...

  10. Message deduplication 这里的去重与你想的可能不一样|Apache Pulsar 技术系列

    导语 Apache Pulsar 是一个多租户.高性能的服务间消息传输解决方案,支持多租户.低延时.读写分离.跨地域复制.快速扩容.灵活容错等特性.腾讯云内部 Pulsar工作组对 Pulsar 做了 ...