UVA 1386 Cellular Automaton】的更多相关文章

UVA 1386 - Cellular Automaton option=com_onlinejudge&Itemid=8&page=show_problem&category=489&problem=4132&mosmsg=Submission+received+with+ID+13911770" target="_blank" style="">题目链接 题意:给定一个n格的环,如今有个距离d.每次变化把环…
矩阵快速幂. 样例是这样构造矩阵的: 矩阵很好构造,但是500*500*500*logk的复杂度显然是无法通过这题的. 其实本题构造出来的矩阵是一个循环矩阵,只需直到第一行或者第一列,即可直到整个矩阵是怎么样的. 所以,中间计算的时候,需要直到第一行是什么即可,即1*n的矩阵乘n*n的矩阵.时间复杂度o(n*n*logk) #include<cstdio> #include<cstring> #include<cmath> #include<vector>…
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=15129 [思路] 矩阵乘法-循环矩阵 题目中的转移矩阵是一个循环矩阵,循环矩阵的乘积依旧是循环矩阵,这样保留矩阵第一行进行快速幂乘法即可. [代码] #include<cstdio> #include<cstring> #include<iostream> using namespace std; typedef long long LL…
http://poj.org/problem?id=3150 这题裸的矩阵很容易看出,假设d=1,n=5那么矩阵是这样的 1 1 0 0 1 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0 0 1 1 这是n^3的,可是n<=500,显然tle 我们观察这个n×n的矩阵,发现没一行都是由上一行向右移得到的. 而根据Cij=Aik×Bkj,我们可以发现,其实Bkj==Akj==Ai(j-k) 那么就可以降二维变一维,每一次只要算第一行即可,即Cj=Ak*Bj-k #includ…
Cellular Automaton Time Limit: 12000MS   Memory Limit: 65536K Total Submissions: 3048   Accepted: 1227 Case Time Limit: 2000MS Description A cellular automaton is a collection of cells on a grid of specified shape that evolves through a number of dis…
题面:UVA1386 Cellular Automaton 矩阵乘法+快速幂解法: 这是一个比较裸的有点复杂需要优化的矩乘快速幂,所以推荐大家先做一下下列洛谷题目练练手: (会了,差不多就是多倍经验题了) 注:如果你还不会矩阵乘法,可以移步了解一下P3390的题解 P1939 [模板]矩阵加速(数列) P3390 [模板]矩阵快速幂 P1962 斐波那契数列 P4910 帕秋莉的手环 P4838 P哥破解密码 然后讲一下本题,读题我们发现这个环上所进行的 k 次操作都是一模一样的,还是相邻的数的…
Cellular Automaton Time Limit: 12000MS Memory Limit: 65536K Total Submissions: 3504 Accepted: 1421 Case Time Limit: 2000MS Description A cellular automaton is a collection of cells on a grid of specified shape that evolves through a number of discret…
A cellular automaton is a collection of cells on a grid of specified shape that evolves through a number of discrete time steps according to a set of rules that describe the new state of a cell based on the states of neighboring cells. The order of t…
题目大意:给定n(1<=n<=500)个数字和一个数字m,这n个数字组成一个环(a0,a1.....an-1).假设对ai进行一次d-step操作,那么ai的值变为与ai的距离小于d的全部数字之和模m.求对此环进行K次d-step(K<=10000000)后这个环的数字会变为多少. 看了一篇博客:http://www.cppblog.com/varg-vikernes/archive/2011/02/08/139804.html说的非常清楚. 拿例子来说: a矩阵: a = 1 2 2…
题目连接:620 - Cellular Structure 题目大意:给出一个细胞群, 判断该细胞的可能是由哪一种生长方式的到的, 输出该生长方式的最后一种生长种类, "SIMPLE" -----------------------由 空 生成 ‘A' "FULLY-GROWN"----------------在 原细胞群(不能为空)的后面 加上  ’AB' MUTANT----------------------在 原细胞群(不能为空)的前后分别加上  ‘A'  …