n^3logn非常显然。所以要用一种因为这个矩阵是一个循环矩阵,所以只要知道第一行就可以知道所有行了。 C[i][j]=C[i-1][j-1];

 #include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
using namespace std;
const int Maxn=;
int n,m,k;
struct Matrix{double a[Maxn];}Ori,Bas,Ans;
inline Matrix operator * (Matrix A,Matrix B)
{
Matrix C; memset(C.a,,sizeof(C.a));
for (int i=;i<=n;i++)
for (int j=;j<=n;j++) C.a[i]+=A.a[j]*B.a[(i-j+n+)%n==?n:(i-j+n+)%n];
return C;
}
inline Matrix Pow(Matrix Base,int Exp)
{
Matrix Ret; memset(Ret.a,,sizeof(Ret.a)); Ret.a[]=;
while (Exp)
{
if (Exp&) Ret=Ret*Base;
Base=Base*Base; Exp>>=;
}
return Ret;
}
int main()
{
scanf("%d%d%d",&n,&m,&k);
for (int i=;i<=n;i++) scanf("%lf",&Ori.a[i]);
Bas.a[]=(double)(m-)/(double)m;
Bas.a[]=/(double)m;
Bas=Pow(Bas,k);
Ans=Bas*Ori;
for (int i=;i<=n;i++) printf("%.3lf\n",Ans.a[i]);
return ;
}

C++

C[1][i]=A[1][k]*B[k][i]; 就可以转换为 C.a[1][i]=A[1][k]*B[1][i-k+1];

类似题目:POJ 3150 HDU 2276 HDU 4576

BZOJ 4204 && BZOJ 2510 循环矩阵的更多相关文章

  1. bzoj 2510: 弱题 循环矩阵

    2510: 弱题 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 124  Solved: 61[Submit][Status][Discuss] De ...

  2. 【BZOJ 2510】 2510: 弱题 (矩阵乘法、循环矩阵的矩阵乘法)

    2510: 弱题 Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 374  Solved: 196 Description 有M个球,一开始每个球均有一 ...

  3. bzoj 2510: 弱题 概率期望dp+循环矩阵

    题目: Description 有M个球,一开始每个球均有一个初始标号,标号范围为1-N且为整数,标号为i的球有ai个,并保证Σai = M. 每次操作等概率取出一个球(即取出每个球的概率均为1/M) ...

  4. 【循环矩阵乘优化DP】BZOJ 2510 弱题

    题目大意 有 \(M\) 个球,一开始每个球均有一个初始标号,标号范围为 \(1\) - \(N\) 且为整数,标号为 \(i\) 的球有 \(a_i\) 个,并保证 \(\sum a_i = M\) ...

  5. BZOJ 4818 [Sdoi2017]序列计数 ——矩阵乘法

    发现转移矩阵是一个循环矩阵. 然后循环矩阵乘以循环矩阵还是循环矩阵. 据说还有FFT并且更优的做法. 之后再看吧 #include <map> #include <cmath> ...

  6. LA 3704 (矩阵快速幂 循环矩阵) Cellular Automaton

    将这n个格子看做一个向量,每次操作都是一次线性组合,即vn+1 = Avn,所求答案为Akv0 A是一个n*n的矩阵,比如当n=5,d=1的时候: 不难发现,A是个循环矩阵,也就是将某一行所有元素统一 ...

  7. UVA 1386 - Cellular Automaton(循环矩阵)

    UVA 1386 - Cellular Automaton option=com_onlinejudge&Itemid=8&page=show_problem&category ...

  8. hihocoder 1388 fft循环矩阵

    #1388 : Periodic Signal 时间限制:5000ms 单点时限:5000ms 内存限制:256MB 描述 Profess X is an expert in signal proce ...

  9. UVaLive 3704 Cellular Automaton (循环矩阵 + 矩阵快速幂)

    题意:一个细胞自动机包含 n 个格子,每个格子取值是 0 ~ m-1,给定距离,则每次操作后每个格子的值将变成到它距离不超过 d 的所有格子在操作之前的值之和取模 m 后的值,其中 i 和 j 的距离 ...

随机推荐

  1. 判断一个url地址是不是404状态(用curl函数)

    <?php $url = "http://www.kxblogs.com/n/20161108/74429879.html"; $ch = curl_init (); cur ...

  2. java web 之 SpringMVC4.x配置

    合肥程序员群:49313181.    合肥实名程序员群:128131462 (不愿透露姓名和信息者勿加入) Q  Q:408365330     E-Mail:egojit@qq.com 综述: 有 ...

  3. ALV Tree demo(WBS元素分层显示)[引用别人的]

    原文地址:http://www.xuebuyuan.com/1666753.html 按层次显示WBS编码及描述,附加节点双击展开事件和Item双击跳转CJ03功能. 因为本人懒,本例代码都是从标准的 ...

  4. JS学习笔记01

    文章转载pigpigpig4587 的 1.Javascript是区分大小写的语言.也就是说.关键字.变量,函数和所有的标识符都必须采取一致的大小写形式.因为html不严格区分大小写,所以在html中 ...

  5. 矩阵k次幂 采用三重循环

    #include<iostream> using namespace std; int main() { int n,k; ][],b[][],c[][]; while(cin>&g ...

  6. The type String cannot be constructed. You must configure the container to supply this value.

    利用 Enterprise Library 5.0 Microsoft.Practices.EnterpriseLibrary.Common Microsoft.Practices.Enterpris ...

  7. sql 多行转换为一行

    select 字段1, [val]=( select 字段2 +',' from 表名 as b where b.字段1 = a.字段1  for xml path('')) from 表名 as a ...

  8. 1476. Lunar Code

    http://acm.timus.ru/problem.aspx?space=1&num=1476 由于前一列对后一列有影响,所以需要保持前一列的状态, 但无需用状态压缩来保存(也保存不了) ...

  9. (DFS、全排列)POJ-2718 Smallest Difference

    题目地址 简要题意: 给若干组数字,每组数据是递增的在0--9之间的数,且每组数的个数不确定.对于每组数,输出由这些数组成的两个数的差的绝对值最小是多少(每个数出现且只出现一次). 思路分析: 对于n ...

  10. nginx 安装与配置

    centos7环境下nginx的安装  版本 0.85 tar zxvf nginx.tar.gz cd nginx ./configure // ./configure --help 查看编译选项 ...