\(\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. js 对 date 和 字符串 类型的正确互换【各浏览器兼容】,解决invalid Date

    1.前言 有个需求,想要把指定日期时间的字符串转换成date类型 pc浏览器正常转换,但手机浏览器 返回结果是 invalid Date [无效的日期] 2.原因 出现这样不兼容的原因其实很简单, p ...

  2. RabbitMQ 消息中间件 的下载与安装【window10】

    1.前言 弄了好久,才终于把 rabbitmq装好 ,本来是很简单的,但是,安装有个要求就是路径不能有中文字符, 虽然可以安装,但是无法运行,需要修改路径名为非中文字符后重装rabbitmq才可以运行 ...

  3. vue中computed的作用以及用法

    在vue中computed是计算属性,主要作用是把数据存储到内存中,减少不必要的请求,还可以利用computed给子组件的data赋值. 参考地址:https://www.jianshu.com/p/ ...

  4. 解读与部署(三):基于 Kubernetes 的微服务部署即代码

    在基于 Kubernetes 的基础设施即代码一文中,我概要地介绍了基于 Kubernetes 的 .NET Core 微服务和 CI/CD 动手实践工作坊使用的基础设施是如何使用代码描述的,以及它的 ...

  5. kafka时间轮的原理(一)

    概述 早就想写关于kafka时间轮的随笔了,奈何时间不够,技术感觉理解不到位,现在把我之前学习到的进行整理一下,以便于以后并不会忘却.kafka时间轮是一个时间延时调度的工具,学习它可以掌握更加灵活先 ...

  6. Kafka connector (kafka核心API)

    前言 Kafka Connect是一个用于将数据流输入和输出Kafka的框架.Confluent平台附带了几个内置connector,可以使用这些connector进行关系数据库或HDFS等常用系统到 ...

  7. [MRCTF2020]Ezaudit

    [MRCTF2020]Ezaudit 知识点 1.源码泄露 2.伪随机数 3.sql注入? 题解 打开题目是个漂亮的前端,扫一下发现www.zip文件泄露,下载审计 <?php header(' ...

  8. Java传递变量和对象的区别

    传递对象 public class Demo03 { //引用传递:(实际上还是值传递)对于引用数据类型来说,传递的则是地址的副本(对象的地址).但由于地址副本和原来的类似,因此传递过去后形参也只想同 ...

  9. INFO client.RMProxy: Connecting to ResourceManager at hadoop

    1.查看防火墙是否没关闭. 2.用jps 命令查看是否没有启动resourcemanager

  10. 【记录一个问题】thanos receiver的日志中出现错误:conflict

    完整的错误如下: level=debug ts=2021-08-16T09:07:43.412451Z caller=handler.go:355 component=receive componen ...