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\) ...
随机推荐
- Spring3.x JSR-303
JSR303介绍 JSR303-Bean Validation描述:This JSR will define a meta-data model and API for JavaBeanTM vali ...
- django的manytomany总结
from django.db import models class Blog(models.Model): name = models.CharField(max_length=100) tagli ...
- innerHTML和innerText怎么区分
示例代码:<div id="test"> <span style="color:red">test1</span> test ...
- [转]json-lib 的maven dependency
转载自http://www.cnblogs.com/yqskj/archive/2013/05/27/3101934.html 项目中要用到json-lib,mvnrepository.com查找它的 ...
- flyplane
看到别人的一个简单制作打飞机的demo,先保存下来有空可以研究一下: <!DOCTYPE html> <html lang="en"> <head&g ...
- Yii2 Post请求的时候出现400错误
Bad Request (#400) Unable to verify your data submission. http://www.yiiframework.com/forum/index. ...
- jinja2的一些用法
1.split用法以及乘法运算 {% set user_list=l.users.split(',') %} <tr> <td>{{ l.name }}</td> ...
- AngularJS绑定数据
绑定数据总共有三种方式1.{{}}最常用2.ngbind3.ng-model 主要用在input标签
- php写一个判断是否有cookie的脚本
前言: 刚刚学习完cookie函数,写个练习. 0x01: //其实第二个应该改为elseif,但是我懒.啊哈 <?php $vlas="BnJhiFoPS4"; if(is ...
- krpano之背景音乐
步骤: 1.添加音乐控制插件 <!-- START:音乐控制 --> <plugin name="soundinterface" url="%SWFPA ...