【poj3150】Cellular Automaton
来源:互联网 发布:粒子群算法详解和实例 编辑:程序博客网 时间:2024/05/19 00:49
http://hzwer.com/1817.html
#include<iostream>#include<cstring>#include<cstdio>#define ll long longusing namespace std;ll n,m,d,k;ll num[500],a[500],b[500];void prll(ll a[]){for(ll i=0;i<n;i++)cout<<a[i]<<' ';cout<<endl;}void mul(ll a[],ll b[],ll ans[]){ ll t[500]; memset(t,0,sizeof(t)); for(ll i=0;i<n;i++) for(ll k=0;k<n;k++) if(i-k>=0)t[i]=(t[i]+(a[k]*b[i-k])%m)%m; else t[i]=(t[i]+(a[k]*b[i-k+n])%m)%m; for(ll i=0;i<n;i++)ans[i]=t[i];}int main(){ scanf("%d%d%d%d",&n,&m,&d,&k); for(ll i=0;i<n;i++)scanf("%d",&num[i]); for(ll i=0;i<=d;i++)a[i]=1; for(ll i=n-1;i>=n-d;i--)a[i]=1; b[0]=1; while(k) { if(k&1)mul(b,a,b); k>>=1; mul(a,a,a); } mul(num,b,num); prll(num); return 0;}
0 0
- poj3150 Cellular Automaton
- 【poj3150】Cellular Automaton
- POJ3150---Cellular Automaton(矩阵)
- POJ3150 Cellular Automaton 矩阵的应用
- poj3150--Cellular Automaton(矩阵优化)
- poj3150 Cellular Automaton(矩阵快速幂)
- [FFT] [矩阵快速幂] [POJ3150] Cellular Automaton
- poj3150 && LA3704 Cellular Automaton 矩阵乘法 + 循环矩阵性质
- poj 3150 Cellular Automaton
- POJ 3150 Cellular Automaton
- POJ Cellular Automaton
- poj 3150 Cellular Automaton
- POJ 3150 Cellular Automaton
- UVA - 1386 Cellular Automaton
- UVa 1386 - Cellular Automaton
- poj 3150 Cellular Automaton
- POJ 3150 Cellular Automaton
- UVA 1386 Cellular Automaton
- 【记录】s5pv210运行裸机程序的方法之在SDRAM(DDR2)中运行
- Cocos2d-x3.2中 不让物体飞出屏幕
- 响应式布局学习笔记
- 国内P2P网贷平台的运营模式
- java内存好文章网址
- 【poj3150】Cellular Automaton
- cocos2d-x 3.2 |如何实现图片显示和精灵动画 Sprite
- gcc文件后缀及c程序与传统c++常用的头文件与标准c++头文件
- 【记录】s5pv210烧写裸机文件的方法之烧写到SD卡
- Maria 项目接口重构的主要功能及其实现
- 判断出栈顺序的合理性
- java 树形结构
- PHP+MYSQL+Apache
- git rebase 使用体会