\(\text{FFT}\)

#include <cstdio>
#include <cmath>
#include <iostream>
#include <cstring>
#define re register
using namespace std; const int N = 2e6 + 1e5;
int c[N], rev[N];
char s[N]; const double Pi = acos(-1.0);
struct complex{
double x, y;
inline complex(double xx = 0, double yy = 0){x = xx, y = yy;}
inline complex operator + (const complex &b) const {return complex(x + b.x, y + b.y);}
inline complex operator - (const complex &b) const {return complex(x - b.x, y - b.y);}
inline complex operator * (const complex &b) const {return complex(x * b.x - y * b.y, x * b.y + y * b.x);}
}a[N], b[N]; inline void FFT(complex *a, int lim, int inv)
{
for(re int i = 0; i < lim; i++)
if (i < rev[i]) swap(a[i], a[rev[i]]);
for(re int mid = 1; mid < lim; mid <<= 1)
{
complex I = complex(cos(Pi / mid), inv * sin(Pi / mid));
for(re int i = 0; i < lim; i += mid << 1)
{
complex W = complex(1, 0);
for(re int j = 0; j < mid; j++, W = W * I)
{
complex x = a[i + j], y = W * a[i + j + mid];
a[i + j] = x + y, a[i + j + mid] = x - y;
}
}
}
} int main()
{
scanf("%s", s);
int n = strlen(s);
for(re int i = 0; i < n; i++) a[i].x = s[n - i - 1] ^ 48;
scanf("%s", s);
int m = strlen(s);
for(re int i = 0; i < m; i++) b[i].x = s[m - i - 1] ^ 48; int limit = 1;
while (limit < n + m - 1) limit <<= 1;
int bit = 0;
while ((1 << bit) < limit) ++bit;
for(re int i = 0; i < limit; i++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (bit - 1)); FFT(a, limit, 1), FFT(b, limit, 1);
for(re int i = 0; i < limit; i++) a[i] = a[i] * b[i];
FFT(a, limit, -1);
for(re int i = 0; i < limit; i++) c[i] = int(a[i].x / limit + 0.5);
for(re int i = 0; i < limit; i++)
{
if (c[i] >= 10) c[i + 1] += c[i] / 10, limit = ((i + 1) == limit ? limit + 1 : limit);
c[i] %= 10;
}
while (limit && !c[limit]) --limit;
for(re int i = limit; i >= 0; i--) printf("%d", c[i]);
}

\(\text{NTT}\)

#include <cstdio>
#include <iostream>
#include <cstring>
#define re register
using namespace std; const int N = 2e6 + 1e5;
const int P = 998244353, g = 3;
int a[N], b[N], rev[N];
char s[N]; inline int fpow(int x, int y)
{
int res = 1;
for(; y; y >>= 1)
{
if (y & 1) res = 1LL * res * x % P;
x = 1LL * x * x % P;
}
return res;
} inline void NTT(int *a, int lim, int inv)
{
if (lim == 1) return;
for(re int i = 0; i < lim; i++)
if (i < rev[i]) swap(a[i], a[rev[i]]);
for(re int mid = 1, I; mid < lim; mid <<= 1)
{
I = fpow(g, (P - 1) / (mid << 1));
if (inv == -1) I = fpow(I, P - 2);
for(re int i = 0, W; i < lim; i += mid << 1)
{
W = 1;
for(re int j = 0, x, y; j < mid; j++, W = 1LL * W * I % P)
{
x = a[i + j], y = 1LL * W * a[i + j + mid] % P;
a[i + j] = (x + y) % P, a[i + j + mid] = (x - y + P) % P;
}
}
}
} int main()
{
scanf("%s", s);
int n = strlen(s);
for(re int i = 0; i < n; i++) a[i] = s[n - i - 1] ^ 48;
scanf("%s", s);
int m = strlen(s);
for(re int i = 0; i < m; i++) b[i] = s[m - i - 1] ^ 48; int limit = 1;
while (limit < n + m - 1) limit <<= 1;
int bit = 0;
while ((1 << bit) < limit) ++bit;
for(re int i = 0; i < limit; i++) rev[i] = (rev[i >> 1] >> 1) | ((i & 1) << (bit - 1)); NTT(a, limit, 1), NTT(b, limit, 1);
for(re int i = 0; i < limit; i++) a[i] = 1LL * a[i] * b[i] % P;
NTT(a, limit, -1);
int inv = fpow(limit, P - 2);
for(re int i = 0; i < limit; i++) a[i] = 1LL * a[i] * inv % P;
for(re int i = 0; i < limit; i++)
{
if (a[i] >= 10) a[i + 1] += a[i] / 10, limit = ((i + 1) == limit ? limit + 1 : limit);
a[i] %= 10;
}
while (limit && !a[limit]) --limit;
for(re int i = limit; i >= 0; i--) printf("%d", a[i]);
}

LG P1919的更多相关文章

  1. Linux下安装性能测试负载机LG

    系统:CentOS release 6.6 (Final)  x86_64 安装包: 1.LRLG_00031.iso [Load Generator Standalone (Linux 64-bit ...

  2. bootstrap 之 xs,sm,md,lg && 主要颜色

    mobile – xs ( <768px ) tablet – sm ( 768~991px ) desktop – md ( 992~1170px ) large desktop – lg ( ...

  3. boostrap中lg,md,sm,xs

    boostrap中lg,md,sm,xs分别表示多少px? .col-xs- 超小屏幕 手机 (<768px).col-sm- 小屏幕 平板 (≥768px).col-md- 中等屏幕 桌面显示 ...

  4. LG 2.2.1 P350安卓系统刷机,问题总结,希望对需要的朋友有助

    手机误删软件导致短信,键盘等无声音提醒 我的手机前几天被我误删了一个软件,导致电话接不了,别人打电话的时候,老提示我在通话中,但是我可以在通话中看到对方的打电话记录.短信,键盘,USB连接,等等都没有 ...

  5. 美版nexus 5 LG D820才支持CDMA,国际版LG D821不支持

    我们都知道nexus 5其实是有两个不同的版本的,分别是LG D820和LG D821,它们在几乎所有的配置和外观上都没有任何的区别,主要区别在通讯模块上,一个支持GSM/CDMA/WCDMA/LTE ...

  6. 洛谷P1919 【模板】A*B Problem升级版 题解(FFT的第一次实战)

    洛谷P1919 [模板]A*B Problem升级版(FFT快速傅里叶) 刚学了FFT,我们来刷一道模板题. 题目描述 给定两个长度为 n 的两个十进制数,求它们的乘积. n<=100000 如 ...

  7. git lg 使用 转

    命令: git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yello ...

  8. git lg 配置

    git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d ...

  9. 国行 lg g3 D858 刷 lg g3 D858hk 教程(备忘)

    纯手打,转载请注明出处~ 刷机有风险,出现问题概不负责! 本着自娱自乐的宗旨 ,分享一下,出了问题不负责! 准备的材料: 1,手机一枚(废话)国行lg g3 d858 2,root 工具 用来root ...

  10. LG Optimus L90 [D415] T-Mobile 刷机

    1 先使用[ROOT大师]ROOT手机. 2 执行以下ADB命令. adb shell su //备份 dd /by-name/laf of=/sdcard/laf.img. //清除 dd /by- ...

随机推荐

  1. easui datagrid 行获取后台sql所有数据:支持行chockbox多选,输出选中行任意属性;支持点击表中属性实现跳转;支持分页。

    easyUI datagrid 代码: <table id="tabgrid20170726191838251403" class="easyui-datagrid ...

  2. whylogs工具库的工业实践!机器学习模型流程与效果监控 ⛵

    作者:韩信子@ShowMeAI 机器学习实战系列:https://www.showmeai.tech/tutorials/41 本文地址:https://www.showmeai.tech/artic ...

  3. Python requests 上传文件(以上传图片为例)

    from requests_toolbelt import MultipartEncoderimport requests encoderl = MultipartEncoder( fields = ...

  4. Flask框架使用SQLAlchemy的ORM

    SQLAlchemy 1.介绍 SQLAlchemy是一个基于Python实现的ORM框架.该框架建立在 DB API之上,使用关系对象映射进行数据库操作,简言之便是:将类和对象转换成SQL,然后使用 ...

  5. 分布式日志:Exceptionless的安装与部署

    安装步骤 首先exceptionless依赖elasticsearch,而elasticsearch需要java环境,所以先安装jdk jdk下载地址:https://www.oracle.com/t ...

  6. before-after-hook钩子函数

    before-after-hook 最近看别人的代码,接触到一个插件,before-after-hook,百度搜一圈也没有看到什么地方有教程,看这个字面意思是一个hook,和axios里面的拦截器,v ...

  7. ConditionAlOnProperties实现可插拔?

    大家好,我是3y,一年CRUD经验用十年的markdown程序员‍常年被誉为职业八股文选手 我又又又又被吐槽了,随之而来,我的消息推送平台开源项目Austin又又又又更新啦,迭代自己的项目多是一件美事 ...

  8. Linux安装&卸载mysql5.7

    Linux系统下卸载mysql 停止mysql服务 systemctl stop mysqld.service 查看安装的mysql服务 rpm -qa|grep -i mysql 删除安装的mysq ...

  9. Java中Elasticsearch 实现分页方式(三种方式)

    目录 ES 简介 ES 的特点: 一.from + size 浅分页 二.scroll 深分页 scroll删除 三.search_after 深分页 ES 简介 Elasticsearch 是一个基 ...

  10. python进阶之路11 闭包函数 装饰器

    函数名的多种用法 函数名其实绑定的也是一块内存地址 只不过该地址里面存放的不是数据值而是一段代码 函数名加括号就会找到该代码并执行 1.可以当作变量名赋值 def index():pass res = ...