码迷,mamicode.com
首页 >  
搜索关键字:矩阵快速幂    ( 1404个结果
VOJ 1067 Warcraft III 守望者的烦恼 (矩阵快速幂+dp)
显然可知 dp[n] = dp[n-k] + dp[n-k+1] + ... +dp[n-1]; 然后要用矩阵来优化后面的状态转移。 也就是矩阵 0 1 0 0    a     b 0 0 1 0 * b =  c 0 0 0 1    c     d 1 1 1 1    d    a+b+c+d 然后跑快速幂 #include #inclu...
分类:其他好文   时间:2014-06-16 12:40:59    阅读次数:237
hdu 1757 A Simple Math Problem (矩阵快速幂)
和这一题构造的矩阵的方法相同。 需要注意的是,题目中a0~a9 与矩阵相乘的顺序。 #include #include #include #include #include #define N 10 using namespace std; int mod; typedef long long LL; struct matrix { LL a[10][10]; }...
分类:其他好文   时间:2014-06-16 12:06:07    阅读次数:231
hdu 2157 How many ways?? (矩阵快速幂)
题目大意: 问A-B 走K 部的方法数。 如果矩阵 a 为任意一个点到另外一个点 走 1 步的方法数 那么 a*a 就是任意一个点到另外一个点 走 2 步的方法数 。。。 那么直接快速幂。 #include #include #include #include #include #define N 10 using namespace std; in...
分类:其他好文   时间:2014-06-15 18:02:55    阅读次数:212
poj 3150 Cellular Automaton(矩阵快速幂)
http://poj.org/problem?id=3150 大致题意:给出n个数,问经过K次变换每个位置上的数变为多少。第i位置上的数经过一次变换定义为所有满足 min( abs(i-j),n-abs(i-j) ) 思路: 我们先将上述定义表示为矩阵 B =  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...
分类:其他好文   时间:2014-06-15 16:14:14    阅读次数:169
Acdreamoj1116(Gao the string!)字符串hash+二分+矩阵快速幂
Problem Description give you a string, please output the result of the following function mod 1000000007 n is the length of the string f() is the function of fibonacci, f(0) = 0, f(1) = 1... a...
分类:其他好文   时间:2014-06-14 11:45:49    阅读次数:243
矩阵快速幂
复杂度为o(n^3logk) /* 求 a^k % mod,其中a是n*n的矩阵 */ const int mod = 10000; const int maxn = 2; _LL k; int n; struct matrix { _LL mat[maxn][maxn]; } a,res; matrix mul(matrix x, matrix y) { matrix tmp...
分类:其他好文   时间:2014-06-14 07:46:19    阅读次数:206
Light OJ 1268 Unlucky Strings 矩阵快速幂+KMP
题目来源:Light OJ 1268 Unlucky Strings 题意:给你一些可以用的字符 然后求组成不包含给定字符串的方案数 思路:矩阵经典问题 从i走k步路到达j的方案数 可以用矩阵快速幂求解 对于求长度为n的字符的方案数 就是走n步路 求走法 可以用KMP求出走一步 从前i个字符到前j个字符的方案数 这点有点不好理解 想一想 #include #include #...
分类:其他好文   时间:2014-06-07 14:33:43    阅读次数:303
POJ 3744 Scout YYF I 矩阵快速幂
Scout YYF ITime Limit: 1000MSMemory Limit: 65536KTotal Submissions: 4452Accepted: 1159DescriptionYYF is a couragous scout. Now he is on a dangerous mi...
分类:其他好文   时间:2014-05-28 19:00:38    阅读次数:289
BNUOJ 34985 Elegant String 2014北京邀请赛E题 矩阵快速幂
题目链接:http://acm.bnu.edu.cn/bnuoj/problem_show.php?pid=34985题目大意:问n长度的串用0~k的数字去填,有多少个串保证任意子串中不包含0~k的某一个全排列邀请赛上A的较多的一道题,比赛的时候死活想不出,回来之后突然就想通了,简直..... = ...
分类:其他好文   时间:2014-05-28 18:38:04    阅读次数:327
ACdream 1093 女神的正多面体 矩阵快速幂
题目大意:给你三种正多边形,给你起点s,终点e以及最多行走的步数k,问有多少种路径方案(路径中只要有一个顶点不同即视为不同)。题目分析:可以通过矩阵快速幂求解。为每个正多边形(最多三个)构建一个邻接矩阵A,然后第K步的方案数即为A^k。结果即为A^1 + A^2 + A^3 + ...... + A...
分类:其他好文   时间:2014-05-25 11:35:24    阅读次数:178
1404条   上一页 1 ... 137 138 139 140 141 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!