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\) ...
随机推荐
- self = [super init] 最终解释
答: init 中调用super的 init方法来初始化自己所包含有的父类信息 1.内存分配 内存应该在[Class alloc]的时候就已经分配了,大小和类型应该由对应的Clas ...
- 11.7noip模拟赛
题解:广义斐波那契数列 矩阵乘法 #include<iostream> #include<cstdio> #include<cstring> #define LL ...
- 1.2 java web的发展历史
前言 了解java web的发展历史和相关技术的演进历程,非常有助于加深对java web技术的理解和认识. 阅读目录 1.Servlet的出现 2.Jsp的出现 3.倡导了MVC思想的Servlet ...
- jquery移除、绑定、触发元素事件
unbind(type [,data]) //data是要移除的函数 $('#btn').unbind("click"); //移除click $('#btn').unbind() ...
- VBA程序的调试
VBA程序的调试:设置断点.单步跟踪.设置监视窗 Acces的VBE编程环境提供了完整的一套调试工具和调试方法.熟练掌握好这些调试工具和调试方法的使用,可以快速.准确地找到问题所在,不断修改,加以完善 ...
- mysql concat的使用
想要在一个id前都加个0,如果处理呢? mysql concat的使用 update `a_data` set id=CONCAT('0', id) where data_packet_id in ( ...
- java多线程-------------基础的Thread.CURRNET
总结:感觉不是太难,不过我写出来了,但竟然不理解它的意思?多线程就是多个任务同时进行 public class Test2 { public static void main(String[] arg ...
- java代码求奖金。要求从键盘输入利润
总结:看似文字描述很多, package com.ai; import java.util.Scanner; import com.b.Scaner; //v企业发放的奖金根据利润提成.利润(I)低于 ...
- TCP之四:TCP 滑动窗口协议 详解
滑动窗口机制 滑动窗口协议的基本原理就是在任意时刻,发送方都维持了一个连续的允许发送的帧的序号,称为发送窗口:同时,接收方也维持了一个连续的允许接收的帧的序号,称为接收窗口.发送窗口和接收窗口的序号的 ...
- Linux学习笔记 - Shell 运算符篇
Shell 运算符分类 Shell 和其他编程语言一样,支持多种运算符,包括: 算数运算符 关系运算符 布尔运算符 字符串运算符 文件测试运算符 算数运算符 首先,使用 shell 算数运算符是,需要 ...