传送门

分析

我们可以将所有的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的更多相关文章

  1. 【CF453D】 Little Pony and Elements of Harmony(FWT)

    题面 传送门 设\(a\)的递推公式为 \[a_i=\sum_ja_jb[count(i\oplus j)]\] 其中\(\oplus\)为异或,\(count(i)\)表示\(i\)的二进制中\(1 ...

  2. [CF453D]Little Pony and Elements of Harmony

    题目   点这里看题目. 分析   设\(count(x)\)为\(x\)的二进制中\(1\)的个数.因此\(f(u,v)=count(u\oplus v)\)   看一看每次转移,我们发现最不友好的 ...

  3. CF453(Div1 简单题解)

    A .Little Pony and Expected Maximum pro:给定M,N,表示一个M面的骰子,甩N次,问出现的最大的数的期望. sol:容斥,f(i)表示最大数<=i的期望,那 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. codeforces Round #259(div2) D解决报告

    D. Little Pony and Harmony Chest time limit per test 4 seconds memory limit per test 256 megabytes i ...

  8. Codeforces 4538 (状态压缩dp)Little Pony and Harmony Chest

    Little Pony and Harmony Chest 经典状态压缩dp #include <cstdio> #include <cstring> #include < ...

  9. [CF453B]Little Pony and Harmony Chest

    [CF453B]Little Pony and Harmony Chest 题目大意: 给你一个长度为\(n(n\le100)\)的正整数序列\(A(A_i\le30)\),求一个正整数序列\(B\) ...

随机推荐

  1. spring源码学习之:springAOP实现底层原理

    一:springAOP底层实现是基于动态代理实现的.增强和切面,以及通知.是在动态代理生成的代理类inoke方法中调用实现 //+++++++++++++aop动态代理++++++++++++++++ ...

  2. MySQL插入中文时出现ERROR 1406 (22001): Data too long for column 'name' at row 1 (转)

    使用命令行方式登陆到MySQL服务器, 建立一个数据库,数据库编码设为UTF-8.此时,如果直接在命令行窗口使用insert语句插入中文,就遇到类似 ERROR 1406 (22001): Data ...

  3. 集群/分布式环境下,Session处理策略

    前言 在搭建完集群环境后,不得不考虑的一个问题就是用户访问产生的session如何处理.如果不做任何处理的话,用户将出现频繁登录的现象.比如集中中存在A.B两台服务器,用户在第一次访问网站是,Ngin ...

  4. AngularJS:Select

    ylbtech-AngularJS:Select 1.返回顶部 1. AngularJS Select(选择框) AngularJS 可以使用数组或对象创建一个下拉列表选项. 使用 ng-option ...

  5. 使用Revel(go)开发网站(全面版)

    Revel很好的利用了Go语言的goroutine,把每一个request都分配到了goroutine里.不用再写一大堆的回调.如果你写过nodejs的话就会深刻的体会到callback hell是什 ...

  6. java 最差实践

    HashMap size 陷阱: 错误写法: Map map = new HashMap(collection.size()); for (Object o : collection) { map.p ...

  7. 第一章 为什么使用NoSQL

    1.1 关系型数据库的价值 1.1.1 获取持久化数据 1.1.2 并发 通过”事务“ 来控制,出错有“回滚”机制. 1.1.3 集成                共享数据库集成,多个应用程序将数据 ...

  8. Unity3D的坑系列:打包Assetbundle丢失Shader问题(贴图显示不了)

    从Unity4.2开始,为了减少首包大小,不会默认将所有Shader引擎加到游戏程序中,据Unity技术支持人员所说,Unity会将Shader引擎打包到Assetbundle资源中,但是我测试发现不 ...

  9. 命令提示符(cmd)中的tracert命令详解(小技巧)

    tracert也被称为Windows路由跟踪实用程序,在命令提示符(cmd)中使用tracert命令可以用于确定IP数据包访问目标时所选择的路径.本文主要探讨了tracert命令的各个功能. 百度经验 ...

  10. PHP函数(一)-变量

    1.全局变量 <?php $a = 1; $b = 2; function test(){ echo $a + $b."<br>"; //运行结果为0 } tes ...