https://www.oj.swust.edu.cn/problem/show/2781

式子很好推

很明显卷积即可

可以使用

NTT或者拆系数FFT

这里使用的是NTT

#include <algorithm>
#include <cstdio>
#include <cstring>
#include<iostream>
using namespace std;
int mod=1e9+7;
namespace Math
{
inline int pw(int base, int p, const int mod)
{static int res;for (res = 1; p; p >>= 1, base = static_cast<long long> (base) * base % mod) if (p & 1) res = static_cast<long long> (res) * base % mod;return res;
}
inline int inv(int x, const int mod)
{return pw(x, mod - 2, mod);
}
}
using namespace Math;
const int mod1 = 998244353, mod2 = 1004535809, mod3 = 469762049, G = 3;
const long long mod_1_2 = static_cast<long long> (mod1) * mod2;
const int inv_1 = Math::inv(mod1, mod2), inv_2 = Math::inv(mod_1_2 % mod3, mod3);
struct Int
{int A, B, C;explicit inline Int() { }explicit inline Int(int __num) : A(__num), B(__num), C(__num) { }explicit inline Int(int __A, int __B, int __C) : A(__A), B(__B), C(__C) { }static inline Int reduce(const Int &x){return Int(x.A + (x.A >> 31 & mod1), x.B + (x.B >> 31 & mod2), x.C + (x.C >> 31 & mod3));}inline friend Int operator + (const Int &lhs, const Int &rhs){return reduce(Int(lhs.A + rhs.A - mod1, lhs.B + rhs.B - mod2, lhs.C + rhs.C - mod3));}inline friend Int operator - (const Int &lhs, const Int &rhs){return reduce(Int(lhs.A - rhs.A, lhs.B - rhs.B, lhs.C - rhs.C));}inline friend Int operator * (const Int &lhs, const Int &rhs){return Int(static_cast<long long> (lhs.A) * rhs.A % mod1, static_cast<long long> (lhs.B) * rhs.B % mod2, static_cast<long long> (lhs.C) * rhs.C % mod3);}inline int get(){long long x = static_cast<long long> (B - A + mod2) % mod2 * inv_1 % mod2 * mod1 + A;return (static_cast<long long> (C - x % mod3 + mod3) % mod3 * inv_2 % mod3 * (mod_1_2 % mod) % mod + x) % mod;}
} ;#define maxn 131072namespace Poly
{
#define N (maxn << 1)
int lim, s, rev[N];
Int Wn[N | 1];
inline void init(int n)
{s = -1, lim = 1;while (lim < n) lim <<= 1, ++s;for (register int i = 1; i < lim; ++i) rev[i] = rev[i >> 1] >> 1 | (i & 1) << s;const Int t(Math::pw(G, (mod1 - 1) / lim, mod1), Math::pw(G, (mod2 - 1) / lim, mod2), Math::pw(G, (mod3 - 1) / lim, mod3));*Wn = Int(1);for (register Int *i = Wn; i != Wn + lim; ++i) *(i + 1) = *i * t;
}
inline void NTT(Int *A, const int op = 1)
{for (register int i = 1; i < lim; ++i) if (i < rev[i]) std::swap(A[i], A[rev[i]]);for (register int mid = 1; mid < lim; mid <<= 1){const int t = lim / mid >> 1;for (register int i = 0; i < lim; i += mid << 1){for (register int j = 0; j < mid; ++j){const Int W = op ? Wn[t * j] : Wn[lim - t * j];const Int X = A[i + j], Y = A[i + j + mid] * W;A[i + j] = X + Y, A[i + j + mid] = X - Y;}}}if (!op){const Int ilim(Math::inv(lim, mod1), Math::inv(lim, mod2), Math::inv(lim, mod3));for (register Int *i = A; i != A + lim; ++i) *i = (*i) * ilim;}
}
#undef N
}
using namespace Poly;
int n, k;
Int A[maxn << 1], B[maxn << 1];
int N=1e5+10;
long long fac[maxn];
long long ner[maxn];
int main()
{fac[0]=1;scanf("%d%d", &n, &k);for(int i=1; i<=N; i++)fac[i]=fac[i-1]*i%mod;n+=1;ner[N]=pw(fac[N],mod-2,mod);for(int i=N-1; i>=0; i--)ner[i]=(ner[i+1]*(i+1))%mod;//阶乘逆元for (int i = 0, x; i < n; ++i){A[i] =Int((int)(ner[i]*pw(i,k,mod)%mod));}for (int i = 0, x; i < n; ++i){B[i] =Int((int)ner[i]);}init(n+n);NTT(A), NTT(B);for (int i = 0; i < lim; ++i) A[i] = A[i] * B[i];NTT(A, 0);for (int i = 1; i < n; ++i){printf("%lld", (long long)(A[i].get())%mod*fac[i]%mod);if(i!=n-1)printf(" ");}return 0;
}

Power oj 2781: 上决╇ф的黑科技 (任意模数NTT|拆系数FFT)相关推荐

  1. power oj 2783: 上决╇ф的精确打击问题

    传送门 分析:很显然,最小割模型分析:很显然,最小割模型分析:很显然,最小割模型 code:code:code: #include <map> #include <list> ...

  2. 上决╇ф的遗言-后缀数组

    https://www.oj.swust.edu.cn/problem/show/2779 题意中文题不说了. 做法:后缀数组,想把两个串连接起来,求sa和height数组,因为题目要求求的公共子串, ...

  3. 上决╇ф的精确打击问题

    题目链接:上决╇ф的精确打击问题 题目大意:给你一个矩阵,矩阵里面有一些士兵,每次可以消灭一行或者一列,或者一个单点,问最小费用. 按行,列,建图,对于每个点,行连向列,权值为点的权值即可. AC代码 ...

  4. 上决╇ф的精确打击问题【最大流】

    题目链接 出题者本人 Description 上决╇ф来到Ceph的洞穴门口,守门的是一个n∗mn∗m的Ceph兵团列阵.上决╇ф的GAUSS 2014电磁轨道反器材步枪,已经充足了电,随时准备与Ce ...

  5. 那些TensorFlow上好玩的和黑科技

    那些TensorFlow上好玩的和黑科技 Google于2017年2月16日(北京时间)凌晨2点在美国加利福尼亚州山景城举办了首届TensorFlow开发者峰会.Google现场宣布全球领先的深度学习 ...

  6. 速围观!上千款“AI黑科技”在此集结

    尬舞机器人.AI虚拟主播.自动驾驶车.5G无人机.仿生人形机器人,在 AIExpo 展会上可谓吸足了眼球. 8月14日,全球人工智能产品博览会(AIExpo 2020)在苏州国际博览中心盛大启幕. 为 ...

  7. 阿里巴巴拿下奥运顶级赞助商 首届云上奥运会拥抱AI黑科技

    1月19日,国际奥委会在瑞士达沃斯宣布,阿里巴巴将加入奥林匹克全球合作伙伴(The Olympic Partner,"TOP")赞助计划,成为"云服务"及&qu ...

  8. 史上最盛大的黑科技年会前夕,阿里妹做了一个重大决定

    摘要: 9月8日,本周五晚上,阿里巴巴集团将在黄龙体育中心召开2017集团年会,来自全球各地的数万名员工都将齐聚杭州. 黄龙体育中心现场 "阿里年会大数据"有多吓人?14班专列.1 ...

  9. 西南科技大学院赛 I题 上决╇ф的精确打击问题 【最大流好题】 建模问题

    传送门 题意: 就是一个矩阵中有些点上面有一些鸟, 然后你可以对每一行或者每一列进行开枪, 会打死这一行或者这一列上面所有的鸟, 然后每一行和每一列都有一个花费, 如果在相应的行(列)开枪就必须付出相 ...

最新文章

  1. brew 安装PHP的配置文件所在位置
  2. MyCat读写分离-笔记(四)
  3. python拆堆和堆叠的操作_python - 如何合并不同的DFS并堆叠值? - 堆栈内存溢出
  4. [TPYBoard - Micropython之会python就能做硬件 7] 学习使用蓝牙模块及舵机
  5. Java黑皮书课后题第6章:6.11(金融应用:计算酬金)编写方法,利用编程练习题5.39中的方法计算酬金。方法头如下所示。编写程序,显示下面表格
  6. 上采样,下采样,过采样,欠采样的区别
  7. Jquery和雅虎的YQL服务实现天气预报功能!
  8. 使用Webpack的代码分离实现Vue懒加载(译文)
  9. python 循环添加array_python常用的基本语句介绍
  10. Java 中nextLine()方法没有执行直接跳过解决办法
  11. [渝粤教育] 西南科技大学 英语(B)1 在线考试复习资料
  12. Linux 脚本修改ps1,Linux使环境变量PS1的修改永久生效——修改配置文件/etc/profile...
  13. ubuntu查看实时网速
  14. [摘]广义企业级PDM系统下的PPM(工艺规划管理)
  15. 计算机网络基础——网络的性能
  16. ag-Grid 超丰富的表格插件(1)——简易使用
  17. x64dbg 基本使用技巧
  18. Java Web(day05) —— 请求和响应
  19. web of science 校外访问方法
  20. 海思PQ调试相关(一)

热门文章

  1. 微服务构建思路与方法论
  2. ARP欺骗的两种方式
  3. Mac-Brew介绍
  4. 最长上升子序列(LIS)问题的解决及优化
  5. 无人机监控交通流量实时传输路况智慧交通系统说明
  6. Mac Office Word设置多级标题
  7. KernelSU: 内核 ROOT 方案, KernelSU KernelSU KernelSU 新的隐藏root防止检测 封号方案
  8. 欧文分校的计算机科学博士,加州大学欧文分校计算机科学硕士排名第37(2020年TFE Times排名)...
  9. Lect2 BFS总结
  10. webpack打包命令报错显示无法加载文件——解决办法