\(RXD\ and\ functions\)

Problem Description

RXD has a polynomial function \(f(x)\), \(f(x)=\sum ^{n}_{i=0}c_ix_i\)

RXD has a transformation of function \(Tr(f,a)\), it returns another function g, which has a property that \(g(x)=f(x−a)\).

Given \(a_1,a_2,a_3,…,a_m\), RXD generates a polynomial function sequence \(g_i\), in which \(g_0=f\) and \(g_i=Tr(g_{i−1},a_i)\)

RXD wants you to find \(g_m\), in the form of \(\sum ^{m}_{i=0}b_ix_i\)

You need to output bi module \(998244353.\)

\(n≤10^5\)

Input

There are several test cases, please keep reading until EOF.

For each test case, the first line consists of \(1\) integer \(n\), which means \(deg\ F\).

The next line consists of \(n+1\) intergers \(c_i\),\(0 \le ci<998244353\), which means the coefficient of the polynomial.

The next line contains an integer \(m\), which means the length of \(a\).

The next line contains \(m\) integers, the \(i\) - th integer is \(a_i\).

There are \(11\) test cases.

\(0\le ai<998244353\)

\(\sum m\le10^5\)

Output

For each test case, output an polynomial with degree n, which means the answer.

Sample Input

2

0 0 1

1

1

Sample Output

1 998244351 1

Hint

\((x - 1) ^ 2 = x^2 - 2x + 1\)

题解:

显然最终操作完的式子为\(\sum_{i=0}^{n}c_i(x-\sum_{i-1}^{m}a_i)^i\)

现在我们记\((-\sum_{i=1}^{m}a_i)\%MOD=a\)

然后变成这样:

\(\sum_{i=0}^{n}c_i(x-a)^i\)

接下来我们对式子进行二项式展开:

\(\sum_{i=0}^{n}\sum_{j=i}^{n}C(j,j-i)c_j\cdot a^{j-i}\cdot x^i\)

用\(j=j-i\)替换\(j\):

\(\sum_{i=0}^{n}\sum_{j=0}^{n-i}C(j+i,j)\cdot c_{j+i}\cdot a^j\cdot x^j\)

把组合数展开:

\(\sum_{i=0}^{n}\sum_{j=0}^{n-i}\frac{(i+j)!}{i!\cdot j!}c_{i+j}\cdot a^j\cdot x^j\)

整理一下,把和内层求和无关的提到外面来得到:

\(\sum_{i=0}^{n}\frac{x^i}{i!}\sum_{j=0}^{n-i}c_{i+j}\cdot (i+j)!\cdot\frac{a^j}{j!}\)

现在我们先怎么转化里面的式子,使之变成卷积的形式:

\(\sum_{j=0}^{n-i}c_{i+j}\cdot (i+j)!\cdot\frac{a^j}{j!}\)

用\(j+k=n-i\)来做替换:

\(\Rightarrow \sum_{j+k=n-i} c_{n-k}\cdot (n-k)!\cdot \frac{a^j}{j!}\)

发现这个式子就是卷积的形式了

令\(A[n]=\sum c_{n-i}\cdot (n-i)!\)

\(B[n]=\sum \frac{a^i}{i!}\)

\(NTT\)来搞即可

//#pragma GCC optimize("O3")
//#pragma comment(linker, "/STACK:1024000000,1024000000")
#include<bits/stdc++.h>
using namespace std;
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MAXN = 1e6+7;
using LL = int_fast64_t;
const LL MOD = 998244353;
const LL g = 3;
int n,limit,m,l,r[MAXN];
LL fact[MAXN],rfact[MAXN],c[MAXN],A[MAXN],B[MAXN];
LL qpow(LL a, LL b){
LL ret = 1;
while(b){
if(b&1) ret = ret * a % MOD;
b >>= 1;
a = a * a % MOD;
}
return ret;
}
LL inv(LL x){ return qpow(x,MOD-2); }
void NTT(LL arr[], int rev){
for(int i = 0; i < limit; i++) if(i<r[i]) swap(arr[i],arr[r[i]]);
for(int len = 1; len < limit; len <<= 1){
LL wn = qpow(g,(MOD-1)/(len<<1));
if(rev==-1) wn = inv(wn);
for(int R = 0; R < limit; R += (len<<1)){
LL w = 1;
for(int i = R; i < R + len; i++){
LL x = arr[i];
LL y = w * arr[i+len] % MOD;
arr[i] = (x+y)%MOD;
arr[i+len] = (x-y+MOD)%MOD;
w = w * wn % MOD;
}
}
}
}
void solve(){
LL a = 0;
for(int i = 0; i <= n; i++) scanf("%I64d",&c[i]);
scanf("%d",&m);
for(int i = 1; i <= m; i++){
int x; scanf("%d",&x);
a -= x;
if(a<0) a += MOD;
}
limit = 1, l = 0;
while(limit<=(n<<1)) limit <<= 1, l++;
for(int i = 0; i < limit; i++) r[i] = ((r[i>>1]>>1) | ((i&1)<<(l-1)));
LL powa = 1;
for(int i = 0; i < limit; i++){
if(i<=n){
A[i] = fact[n-i] * c[n-i] % MOD;
B[i] = powa * rfact[i] %MOD;
powa = powa * a % MOD;
}
else A[i] = B[i] = 0;
}
NTT(A,1); NTT(B,1);
for(int i = 0; i < limit; i++) A[i] = A[i] * B[i] % MOD;
NTT(A,-1);
for(int i = 0; i < limit; i++) A[i] = A[i] * inv(limit) % MOD;
for(int i = 0; i <= n; i++) printf("%I64d ",A[n-i]*rfact[i]%MOD); puts("");
}
int main(){
fact[0] = 1; for(int i = 1; i < MAXN; i++) fact[i] = i * fact[i-1] % MOD;
rfact[MAXN-1] = inv(fact[MAXN-1]);
for(int i = MAXN - 2; i >= 0; i--) rfact[i] = rfact[i+1] * (i+1) % MOD;
while(scanf("%d",&n)!=EOF) solve();
return 0;
}

HDU6061 RXD and functions【NTT】的更多相关文章

  1. 【推导】【NTT】hdu6061 RXD and functions(NTT)

    题意:给定一个n次多项式f(x)的各项系数,让你求f(x-Σai)的各项系数. http://blog.csdn.net/v5zsq/article/details/76780053 推导才是最关键的 ...

  2. 【NTT】loj#6261. 一个人的高三楼

    去年看过t老师写这题博客:以为是道神仙题 题目大意 求一个数列的$k$次前缀和.$n\le 10^5$. 题目分析 [计数]cf223C. Partial Sums 加强版.注意到最后的式子是$f_i ...

  3. POJ 1080 Human Gene Functions 【dp】

    题目大意:每次给出两个碱基序列(包含ATGC的两个字符串),其中每一个碱基与另一串中碱基如果配对或者与空串对应会有一个分数(可能为负),找出一种方式使得两个序列配对的分数最大 思路:字符串动态规划的经 ...

  4. luogu3723 [AH2017/HNOI2017]礼物 【NTT】

    题目 我的室友最近喜欢上了一个可爱的小女生.马上就要到她的生日了,他决定买一对情侣手 环,一个留给自己,一 个送给她.每个手环上各有 n 个装饰物,并且每个装饰物都有一定的亮度.但是在她生日的前一天, ...

  5. 5.24 Declaring Attributes of Functions【转】

    转自:https://gcc.gnu.org/onlinedocs/gcc-4.0.0/gcc/Function-Attributes.html 5.24 Declaring Attributes o ...

  6. Luogu4491 [HAOI2018]染色 【容斥原理】【NTT】

    题目分析: 一开始以为是直接用指数型生成函数,后来发现复杂度不对,想了一下容斥的方法. 对于有$i$种颜色恰好出现$s$次的情况,利用容斥原理得到方案数为 $$\binom{m}{i}\frac{P_ ...

  7. CF528D Fuzzy Search 【NTT】

    题目链接 CF528D 题解 可以预处理出\(S\)每个位置能匹配哪些字符 对每种字符 构造两个序列 如果\(S[i]\)可以匹配该字符,则该位置为\(0\),否则为\(1\) 如果\(T[i]\)可 ...

  8. HDU 6061 RXD and functions(NTT)

    题意 给定一个\(n​\) 次的 \(f​\) 函数,向右移动 \(m​\) 次得到 \(g​\) 函数,第 \(i​\) 次移动长度是 \(a_i​\) ,求 \(g​\) 函数解析式的各项系数,对 ...

  9. 【NTT】hdu1402 A * B Problem Plus

    r·2^k+1 r k g 3 1 1 2 5 1 2 2 17 1 4 3 97 3 5 5 193 3 6 5 257 1 8 3 7681 15 9 17 12289 3 12 11 40961 ...

随机推荐

  1. Docker-ce运用一:创建虚拟机

    1.从远程仓库查看所需镜像 [root@localhost docker]# docker search centos8 NAME                                 DE ...

  2. 2021升级版微服务教程6—Ribbon使用+原理+整合Nacos权重+实战优化 一篇搞定

    2021升级版SpringCloud教程从入门到实战精通「H版&alibaba&链路追踪&日志&事务&锁」 教程全目录「含视频」:https://gitee.c ...

  3. 【Spring】Spring 入门

    Spring 入门 文章源码 Spring 概述 Spring Spring 是分层的 Java SE/EE 应用全栈式轻量级开源框架,以 IOC(Inverse Of Control,反转控制)和 ...

  4. Flutter 基础组件:Widget简介

    概念 在Flutter中几乎所有的对象都是一个Widget.与原生开发中"控件"不同的是,Flutter中的Widget的概念更广泛,它不仅可以表示UI元素,也可以表示一些功能性的 ...

  5. 【Spring】IoC概述

    Spring框架的核心概念--IoC IoC IoC是Inversion of Control的简写,翻译成汉语就是"控制反转".IoC并不是一门技术,而是一种设计思想,在Spri ...

  6. 【Linux】一个网卡部署多个内网ip

    1.用root权限的用户登录CENTOS,进入network-scripts文件夹下(本步骤可以省略,与二步骤一起完成): shell命令:cd /ect/sysconfig/network-scri ...

  7. RCE - Pikachu

    概述: 远程系统命令执行 一般出现这种漏洞,是因为应用系统从设计上需要给用户提供指定的远程命令操作的接口 比如我们常见的路由器.防火墙.入侵检测等设备的web管理界面上 一般会给用户提供一个ping操 ...

  8. eCATT使用前的配置

    如果想在SAP中使用eCATT,必须做一下相关的配置才行,下面简单介绍这几步:1.SM30,输入表T000,然后点击维护,或者是进入事物SCC4,进入对应的clint属性编辑视图下,将CATT and ...

  9. 纯手工撸一个vue框架

    前言 vue create 真的很方便,但是很多人欠缺的是手动撸一遍.有些人离开脚手架都不会开发了. Vue最简单的结构 步骤 搭建最基本的结构 打开空文件夹,通过 npm init 命令生成pack ...

  10. QQ好友状态,QQ群友状态,究竟是推还是拉? 网页端收消息,究竟是推还是拉?

    https://mp.weixin.qq.com/s/KB1zdKcsh4PXXuJh4xb_Zw 网页端收消息,究竟是推还是拉? 原创 58沈剑 架构师之路 2020-12-28   https:/ ...