随笔分类 -  矩阵乘法

 
HDU 5015
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5015矩阵是表示状态转移的利器这题m很大,n非常小,所以开始的思考角度是能否从当前列推出下一列。有了这个角度,矩阵构造是很简单的#include #include #include using namespace ... 阅读全文
posted @ 2015-06-16 16:29 LegendaryAC 阅读(358) 评论(0) 推荐(0)
HDU 2276
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2276矩阵乘法可以解决的一类灯泡开关问题/*转移关系为 now left now*1 0 1 1 1 00 1 10 0 0可知F[i] = (f[i] + f[(n... 阅读全文
posted @ 2015-06-15 18:11 LegendaryAC 阅读(258) 评论(0) 推荐(0)
HDU 2254
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2254矩阵乘法两个经典问题的综合题,还要离散化和处理边界,好题啊好题题意容易理解错,每一天是独立的,所以根据加法原理方案数是G^1+G^2+...+G^t/*此题要求 (G^1+G^2+...+G^t2)-(G^1... 阅读全文
posted @ 2015-06-15 14:21 LegendaryAC 阅读(177) 评论(0) 推荐(0)
矩阵快速幂
摘要:#define MOD 2008#define Mat 35 //矩阵大小 struct mat{//矩阵结构体,a表示内容,r行c列 矩阵从1开始 int a[Mat][Mat]; int r, c; mat() { r = c = 0; ... 阅读全文
posted @ 2014-10-05 01:30 LegendaryAC 阅读(196) 评论(0) 推荐(0)
HDU 2157
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2157求A到B经过K个点的方案数http://www.matrix67.com/blog/archives/276 这里面的经典问题8存图的邻接矩阵自乘k次,得到的新矩阵A行B列就是答案#include #inc... 阅读全文
posted @ 2014-10-05 01:28 LegendaryAC 阅读(207) 评论(0) 推荐(0)
HDU 1757 A Simple Math Problem
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1757还是矩阵+快速幂,注意要把初值乘回去并且注意方向View Code #include using namespace std ;void mul(int a[11][11],int b[11][11],int... 阅读全文
posted @ 2012-08-06 17:03 LegendaryAC 阅读(160) 评论(0) 推荐(0)
HDU 1575 Tr A
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1575矩阵+快速幂A^k是A*A*A...(k个A相乘)View Code #include using namespace std ;void mul(int a[11][11],int b[11][11],in... 阅读全文
posted @ 2012-08-06 11:24 LegendaryAC 阅读(286) 评论(0) 推荐(0)
HDU 2065 "红色病毒"问题
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=2065dp转移方程:dp[i][1]=2*dp[i-1][1]+dp[i-1][2]+dp[i-1][3];dp[i][2]=dp[i-1][1]+2*dp[i-1][2]+dp[i-1][4];dp[i][3]=... 阅读全文
posted @ 2012-08-06 10:34 LegendaryAC 阅读(441) 评论(0) 推荐(0)