453D Little Pony and Elements of Harmony
分析
我们可以将所有的b[i^j]直接对应到b[f(i^j)]上
于是显然可以fwt
我们对b进行t次fwt之后直接将答案与e0卷起来即可
注意由于模数不确定,我们可以将模数扩大$2^m$然后ifwt是直接除掉这个数即可
此题还要使用快速乘
代码
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<ctime>
#include<vector>
#include<set>
#include<map>
#include<stack>
using namespace std;
#define int long long
int m,t,mod,n,a[],b[],d[];
inline void fwt(int a[],int f){
int i,j,k;
for(i=;i<n;i<<=)
for(j=;j<n;j+=(i<<))
for(k=;k<i;k++){
int x=a[j+k],y=a[i+j+k];
a[j+k]=(x+y)%mod,a[i+j+k]=(x+mod-y)%mod;
}
if(f==-)for(i=;i<n;i++)a[i]/=n;
}
inline int mul(int x,int y){
int res=(x*y-(int)((long double)x/mod*y)*mod);
return res<?res+mod:res;
}
inline int pw(int x,int p){
int res=;
while(p){
if(p&)res=mul(res,x);
x=mul(x,x);
p>>=;
}
return res;
}
signed main(){
int i,j,k;
scanf("%I64d%I64d%I64d",&m,&t,&mod);
n=(1ll<<m);
mod*=n;
for(i=;i<n;i++)scanf("%I64d",&a[i]);
for(i=;i<=m;i++)scanf("%I64d",&d[i]);
for(i=;i<n;i++){
k=; for(j=;j<m;j++)
if((<<j)&i)k++;
b[i]=d[k];
}
fwt(a,),fwt(b,);
for(i=;i<n;i++)b[i]=pw(b[i],t);
for(i=;i<n;i++)a[i]=mul(a[i],b[i]);
fwt(a,-);
mod/=n;
for(i=;i<n;i++)printf("%I64d\n",a[i]%mod);
return ;
}
453D Little Pony and Elements of Harmony的更多相关文章
- 【CF453D】 Little Pony and Elements of Harmony(FWT)
题面 传送门 设\(a\)的递推公式为 \[a_i=\sum_ja_jb[count(i\oplus j)]\] 其中\(\oplus\)为异或,\(count(i)\)表示\(i\)的二进制中\(1 ...
- [CF453D]Little Pony and Elements of Harmony
题目 点这里看题目. 分析 设\(count(x)\)为\(x\)的二进制中\(1\)的个数.因此\(f(u,v)=count(u\oplus v)\) 看一看每次转移,我们发现最不友好的 ...
- CF453(Div1 简单题解)
A .Little Pony and Expected Maximum pro:给定M,N,表示一个M面的骰子,甩N次,问出现的最大的数的期望. sol:容斥,f(i)表示最大数<=i的期望,那 ...
- CF453B Little Pony and Harmony Chest (状压DP)
CF453B CF454D Codeforces Round #259 (Div. 2) D Codeforces Round #259 (Div. 1) B D. Little Pony and H ...
- Codeforces Round #259 (Div. 2) D. Little Pony and Harmony Chest 状压DP
D. Little Pony and Harmony Chest Princess Twilight went to Celestia and Luna's old castle to resea ...
- Codeforces Round #259 (Div. 2) D
D. Little Pony and Harmony Chest time limit per test 4 seconds memory limit per test 256 megabytes i ...
- codeforces Round #259(div2) D解决报告
D. Little Pony and Harmony Chest time limit per test 4 seconds memory limit per test 256 megabytes i ...
- Codeforces 4538 (状态压缩dp)Little Pony and Harmony Chest
Little Pony and Harmony Chest 经典状态压缩dp #include <cstdio> #include <cstring> #include < ...
- [CF453B]Little Pony and Harmony Chest
[CF453B]Little Pony and Harmony Chest 题目大意: 给你一个长度为\(n(n\le100)\)的正整数序列\(A(A_i\le30)\),求一个正整数序列\(B\) ...
随机推荐
- C#操作带名称空间的xml
以前操作xml一般用下面这种方式: 好处是XDocument 能使用linq xmlPath = “path”; XDocument myXDoc = XDocument.Load(xmlPath); ...
- elasticsearch snapshot快照备份和恢复
环境:mac 使用brew 安装elasticsearch 1.在 /usr/local/etc/elasticsearch/elasticsearch.yml 文件中配置快照地址 p ...
- excel oracle字段命名(大写下划线分词)转 驼峰命名
干货: (帕斯卡) =LEFT(C251,1)&MID(SUBSTITUTE(PROPER(C251),"_",""),2,100) (驼峰) =LOW ...
- docker 命令记录
从 Docker 镜像仓库获取镜像的命令是 docker pull.其命令格式为: docker pull [选项] [Docker Registry 地址[:端口号]/]仓库名[:标签] 具体的选项 ...
- CentOS中使用Shell脚本实现每天自动备份网站文件和数据库并上传到FTP中(转)
http://www.jb51.net/article/58843.htm 一.安装Email发送程序 复制代码 代码如下: yum install sendmail mutt 二.安装FTP客户端程 ...
- selenium - css 定位
前言: CSS(Cascading Style Sheets)是一种语言,它被用来描述 HTML 和 XML 文档的表现. CSS 使用选择器来为页面元素绑定属性.这些选择器可以被 selenium ...
- rmmod: can't change directory to '/lib/modules': No such file or directory
[root@iTOP-4412]# mount /dev/sda1 /mnt/udisk/ [root@iTOP-4412]# insmod /mnt/udisk/linux/hello.ko [ ...
- mysql 启动卡主,cpu 100%
[mysql@mysqlhq scripts]$ cat /etc/redhat-release Kylin Linux release 3.3.1707 (Core) mysql version S ...
- python's twenty_fourth day for me 内置方法
str repr: 1,当需要使用__str__的场景时找不到__str__就找__repr__ 2,当需要使用__repr__的场景时找不到__repr__的时候就找父类的repr. 3,双下re ...
- GNS3连接虚拟机
打开GNS3,拖一台路由器和主机 右击主机,选择配置 添加虚拟机的网卡为主机网卡,(选择VM1或VM8) 路由器选择虚拟机网卡连接 打开虚拟机在导航栏找到“虚拟机”-->“设 ...