\(\mathcal{Description}\)

  Link.

  给定 \(n\) 次多项式 \(F(x)\),在模 \(998244353\) 意义下求

\[G(x)\equiv\left\{\left[1+\ln\left(2+F(x)-F(0)-\exp \int \frac{1}{\sqrt{F(t)}}\text dt\right)\right]^k\right\}'\pmod{x^n}
\]

其中保证 \(F(0)\) 是模数的二次剩余,开根取模意义下较小常数项值。

  \(n\le10^5\)

\(\mathcal{Solution}\)

  先这样再那样,嗯。

  涉及到多项式 \(\exp\),\(\ln\),求逆,开根,求幂,积分求导,具体推导可以看 这里 哟~

\(\mathcal{Code}\)

/*~Rainybunny~*/

#include <cstdio>
#include <cassert>
#include <cstdlib>
#include <algorithm> #define rep( i, l, r ) for ( int i = l, rep##i = r; i <= rep##i; ++i )
#define per( i, r, l ) for ( int i = r, per##i = l; i >= per##i; --i ) const int MAXL = 1 << 18, MOD = 998244353, INV2 = MOD + 1 >> 1; inline void subeq( int& a, const int b ) { ( a -= b ) < 0 && ( a += MOD ); }
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 void addeq( int& a, const int b ) { ( a += b ) >= MOD && ( 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;
} namespace QResidue { /*
* PolyOper::polySqrt() need this.
* */ int SQRI; struct Complex {
int x, y;
Complex(): x( 0 ), y( 0 ) {}
Complex( const int tx, const int ty ): x( tx ), y( ty ) {}
inline Complex operator * ( const Complex& c ) const {
return Complex( add( mul( x, c.x ), mul( SQRI, mul( y, c.y ) ) ),
add( mul( x, c.y ), mul( y, c.x ) ) );
}
}; inline bool isResidue( const int x ) { return mpow( x, MOD - 1 >> 1 ) == 1; } inline Complex cpow( Complex a, int b ) {
Complex ret( 1, 0 );
for ( ; b; a = a * a, b >>= 1 ) if ( b & 1 ) ret = ret * a;
return ret;
} inline int residue( const int n ) {
if ( !n ) return 0;
if ( !isResidue( n ) ) return -1;
srand( 20120712 ); int a = rand() % MOD;
while ( !a || isResidue( sub( mul( a, a ), n ) ) ) a = rand() % MOD;
SQRI = sub( mul( a, a ), n );
int ret = cpow( Complex( a, 1 ), MOD + 1 >> 1 ).x;
return ret < MOD - ret ? ret : MOD - ret;
} } // namespace QResidue. namespace PolyOper { /* *
* - call init() before any operation;
* - for `poly(n,u,w)', w can't be u;
* - for `poly(n,u,w)', it will only access u[0..n-1] and w[0..n-1];
* - for `poly(n,u,w)', there's no need to clear w before calling them.
* - remember that `n' is always 2^k.
* */ const int MG = 3;
int inv[MAXL + 5], omega[20][MAXL]; inline void init() {
inv[1] = 1;
rep ( i, 2, MAXL + 3 ) inv[i] = mul( MOD - MOD / i, inv[MOD % i] );
rep ( i, 0, 17 ) {
int* oi = omega[i];
oi[0] = 1, oi[1] = mpow( MG, MOD - 1 >> i >> 1 );
rep ( j, 2, ( 1 << i ) - 1 ) oi[j] = mul( oi[j - 1], oi[1] );
}
} inline void ntt( const int n, int* u, const int type ) {
static int rev[MAXL]; rev[0] = 0;
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 ) {
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 ) {
int ivn = MOD - ( MOD - 1 ) / n;
rep ( i, 0, n - 1 ) u[i] = mul( u[i], ivn );
std::reverse( u + 1, u + n );
}
} inline void polyInv( const int n, const int* u, int* w ) {
static int tmp[2][MAXL];
if ( n == 1 ) return void( w[0] = mpow( u[0], MOD - 2 ) );
polyInv( n >> 1, u, w );
rep ( i, 0, ( n >> 1 ) - 1 ) tmp[0][i] = w[i], tmp[1][i] = u[i];
rep ( i, n >> 1, n - 1 ) tmp[0][i] = 0, tmp[1][i] = u[i];
rep ( i, n, ( n << 1 ) - 1 ) tmp[0][i] = tmp[1][i] = 0;
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], sub( 2, mul( tmp[0][i], tmp[1][i] ) ) );
}
ntt( n << 1, tmp[0], -1 );
rep ( i, 0, n - 1 ) w[i] = tmp[0][i];
} inline void polyInt( const int n, const int* u, int* w ) {
w[0] = 0;
rep ( i, 1, n ) w[i] = mul( u[i - 1], inv[i] );
} inline void polyDer( const int n, const int* u, int* w ) {
w[n - 1] = 0;
rep ( i, 0, n - 2 ) w[i] = mul( u[i + 1], i + 1 );
} inline void polyLn( const int n, const int* u, int* w ) {
static int tmp[2][MAXL]; assert( u[0] == 1 );
polyDer( n, u, tmp[0] ), polyInv( n, u, tmp[1] );
rep ( i, n, ( n << 1 ) - 1 ) tmp[0][i] = tmp[1][i] = 0;
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 );
} inline void polyExp( const int n, const int* u, int* w ) {
static int tmp[2][MAXL];
if ( n == 1 ) return assert( !u[0] ), w[0] = 1, void();
polyExp( n >> 1, u, w );
rep ( i, 0, ( n >> 1 ) - 1 ) tmp[0][i] = w[i], tmp[1][i] = 0;
rep ( i, n >> 1, ( n << 1 ) - 1 ) tmp[0][i] = tmp[1][i] = 0;
polyLn( n, tmp[0], tmp[1] ), tmp[1][0] = sub( tmp[1][0], 1 );
rep ( i, 0, n - 1 ) tmp[1][i] = sub( u[i], tmp[1][i] );
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 );
rep ( i, 0, n - 1 ) w[i] = tmp[0][i];
} inline void polySqrt( const int n, const int* u, int* w ) {
static int tmp[2][MAXL];
if ( n == 1 ) return assert( ~( w[0] = QResidue::residue( u[0] ) ) );
polySqrt( n >> 1, u, w ); rep ( i, n >> 1, n - 1 ) w[i] = 0;
polyInv( n, w, tmp[0] );
rep ( i, n, ( n << 1 ) - 1 ) tmp[0][i] = tmp[1][i] = 0;
rep ( i, 0, n - 1 ) tmp[1][i] = u[i];
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 );
rep ( i, 0, n - 1 ) w[i] = mul( add( w[i], tmp[0][i] ), INV2 );
} } // namespace PolyOper. /*** templates are above. ***/ int n, k, tmpF[MAXL + 5], F[MAXL + 5], G[MAXL + 5]; int main() {
PolyOper::init();
scanf( "%d %d", &n, &k ), ++n;
rep ( i, 0, n - 1 ) scanf( "%d", &F[i] ), tmpF[i] = F[i];
int len = 1; for ( ; len < n; len <<= 1 ); PolyOper::polySqrt( len, F, G );
PolyOper::polyInv( len, G, F );
PolyOper::polyInt( len, F, G );
PolyOper::polyExp( len, G, F );
rep ( i, 0, len - 1 ) F[i] = sub( tmpF[i], F[i] );
F[0] = sub( add( F[0], 2 ), tmpF[0] );
PolyOper::polyLn( len, F, G );
G[0] = add( G[0], 1 );
PolyOper::polyLn( len, G, F );
rep ( i, 0, len - 1 ) F[i] = mul( F[i], k );
PolyOper::polyExp( len, F, G );
PolyOper::polyDer( len, G, F ); rep ( i, 0, n - 2 ) printf( "%d%c", F[i], i + 2 < n ? ' ' : '\n' );
return 0;
}

Solution -「LOJ #150」挑战多项式 ||「模板」多项式全家桶的更多相关文章

  1. 「LOJ 556 Antileaf's Round」咱们去烧菜吧

    「LOJ 556 Antileaf's Round」咱们去烧菜吧 最近在看 jcvb 的生成函数课件,顺便切一切上面讲到的内容的板子题,这个题和课件上举例的背包计数基本一样. 解题思路 首先列出答案的 ...

  2. 「WC2016」挑战NPC

    「WC2016」挑战NPC 解题思路 这个题建图非常厉害,带花树什么的只会口胡根本写不动,所以我写了机房某大佬教我的乱搞. 考虑把一个筐 \(x\) 拆成 \(x1,x2,x3\) 三个点,且这三个点 ...

  3. 「LOJ#10051」「一本通 2.3 例 3」Nikitosh 和异或(Trie

    题目描述 原题来自:CODECHEF September Challenge 2015 REBXOR 1​​≤r​1​​<l​2​​≤r​2​​≤N,x⨁yx\bigoplus yx⨁y 表示 ...

  4. 「LOJ#10056」「一本通 2.3 练习 5」The XOR-longest Path (Trie

    #10056. 「一本通 2.3 练习 5」The XOR-longest Path 题目描述 原题来自:POJ 3764 给定一棵 nnn 个点的带权树,求树上最长的异或和路径. 输入格式 第一行一 ...

  5. 火爆的文字游戏你玩了吗?「GitHub 热点速览 v.22.06」

    不知道你有没有被 Wordle 这款游戏刷屏,在本期热点速览的特推部分选了一个 React 编写的开源版本同你分享,而本次公众号摘要也是一个提示, 只不过这个只能盲猜了.别小瞧 Wordle 这个游戏 ...

  6. 用 Java 写个塔防游戏「GitHub 热点速览 v.21.37」

    作者:HelloGitHub-小鱼干 本周 GitHub Trending 的主题词是:多语言.本周特推的 C 语言教程是大家都知道的阮一峰编写的,想必和他之前的技术文章类似,能起到科普作用.再来时 ...

  7. 大型项目源码集合「GitHub 热点速览 v.21.39」

    作者:HelloGitHub-小鱼干 代码,尤其是优雅规范的代码,一直都是学习编程技巧的捷径.虽然有实用的代码小片段,能拯救当前业务的燃眉之急,但是真要去提升自己的技能还是得从大型的项目,尤其是有一定 ...

  8. GitHub 开源的小工具「GitHub 热点速览 v.21.45」

    作者:HelloGitHub-小鱼干 Copilot 是 GitHub 官方出品的代码自动补全工具,之前使用该工具需要有一定的要求.而本周靠 2k+ star 上热点的 copilot-docs 则是 ...

  9. 天冷了,任务栏养只猫吧「GitHub 热点速览 v.21.46」

    作者:HelloGitHub-小鱼干 运动能带来热量,盘猫也是,RunCat_for_windows 是一只奔跑在任务栏的猫,一定能给你的电脑带来一丝冬日的温暖.当然送温暖的除了任务栏小猫咪之外,还有 ...

随机推荐

  1. vue爬坑之路(webpack 配置篇)

    在vue cli下 1.npm run dev 打开浏览器在config的index.js中修改autoOpenBrowser为true 关闭sourcemap productionSourceMap ...

  2. 一文了解Flink State Backends

    原文链接: 一文了解Flink State Backends 当我们使用Flink进行流式计算时,通常会产生各种形式的中间结果,我们称之为State.有状态产生,就必然涉及到状态的存储,那么Flink ...

  3. 一站式搭建 GitHub Pages 博客 (一)

    本文将详细讲解如何快速搭建 GitHub Pages 博客页面 关于博客主题,博客信息更改,上传文章等将会在 一站式搭建 GitHub Pages 博客 (二) 中进行详细讲解 准备阶段 注册 Git ...

  4. Centos7安装erlang以及RabbitMQ Centos启动rabbitmq

    本文使用版本:  rabbitmq-server-3.8.3-1.el7.noarch.rpm   Centos7  erlang  22.3.1 在线安装 yum install esl-erlan ...

  5. CTF中的变量覆盖问题

    0x00 前言 最近在干代码审计,于是就把之前学习的CTF题目中有关变量覆盖的题目结合下进一步研究. 通常将可以用自定义的参数值替换原有变量值的情况称为变量覆盖漏洞.经常导致变量覆盖漏洞场景有:$$使 ...

  6. mybatis关联查询基础----高级映射

    本文链接地址:mybatis关联查询基础----高级映射(一对一,一对多,多对多) 前言: 今日在工作中遇到了一个一对多分页查询的问题,主表一条记录对应关联表四条记录,关联分页查询后每页只显示三条记录 ...

  7. 《剑指offer》面试题33. 二叉搜索树的后序遍历序列

    问题描述 输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历结果.如果是则返回 true,否则返回 false.假设输入的数组的任意两个数字都互不相同.   参考以下这颗二叉搜索树: 5 / \ ...

  8. vue3代码setup中this为什么无效

    结论:setup并没有通过各种方式去绑定this 在vue2中,我们可以在optionsApi中调用this来指向当前组件的实例,但是在vue3的setup中并不能这样做,因为setup位于组件创建成 ...

  9. visual studio进行机器学习与python编写

    visual studio里的python安装之后自带一个虚拟环境 1.anaconda有些包版本无法到最新. 2.包管理器在安装卸载,强制停止后,包管理器会出问题,一直卸不掉那个包. 在卸载pyth ...

  10. C# 同步 异步 回调 状态机 async await Demo

    源码 https://gitee.com/s0611163/AsyncAwaitDemo 为什么会研究这个? 我们项目的客户端和服务端通信用的是WCF,我就想,能不能用异步的方式调用WCF服务呢?或者 ...