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# Socket编程(2)识别网络主机
[转自:https://www.cnblogs.com/IPrograming/archive/2012/10/11/CSharp_Socket_2.html] 一个客户端想要发起一次通信,先决条件就 ...
- webpack新版本4.12应用九(配置文件之模块(module))
这些选项决定了如何处理项目中的不同类型的模块. module.noParse RegExp | [RegExp] RegExp | [RegExp] | function(从 webpack 3.0. ...
- 几个ADB常用命令
http://blog.163.com/ymguan@yeah/blog/static/14007287220133149477594/ 1. 显示当前运行的全部模拟器: adb devices ...
- RbbitMQ基础知识
MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法.应用程序通过读写出入队列的消息(针对应用程序的数据)来通信,而无需专用连接来链接它们.消息传递指的是程序之间 ...
- weblogic11g的安装使用
一.JDK的安装 下载linux环境下的jdk安装文件,本文资源下载:jdk-7u79-linux-x64.tar.gz 将jdk放到linux制定目录下,执行以下命令进行解压操作 tar -zxvf ...
- ecshop其他页面判断是智能手机访问也跳转到ECTouch对应手机版页面(转)
ecshop 其他页面(商品详情页.商品分类页.团购页.优惠活动页.积分商城) 判断如果是智能手机访问跳转到ECTouch1.0手机版对应页面 方法 首先在ecshop 根目录下 includes/l ...
- dpkg安装工具
dpkg --info "软件包名" --列出软件包解包后的包名称. dpkg -l --列出当前系统中所有的包.可以和参数less一起使用在分屏查看. (类似于rpm -qa) ...
- Codeforces Round #318 [RussianCodeCup Thanks-Round] (Div. 1) C. Bear and Drawing
题目链接:http://codeforces.com/contest/573/problem/C题目大意:在两行无限长的点列上面画n个点以及n-1条边使得构成一棵树,并且要求边都在同一平面上且除了节点 ...
- vue参考
https://github.com/taylorchen709/vue-admin http://element-cn.eleme.io/#/zh-CN/component/layout https ...
- SpringMvc入门一----介绍
Spring Mvc简介: Spring Web MVC是一种基于Java的实现了Web MVC设计模式的请求驱动类型的轻量级Web框架,即使用了MVC架构模式的思想,将web层进行职责解耦,基于请求 ...