随笔分类 -  矩阵乘法

摘要:题意: 求 g(g(g(n))) mod 109+ 7 ,其中g(n)=3*g(n-1)+g(n-2), g(0)=0,g(1)=1;分析: 当n 的3的时候内部就超精度了,需要本地暴力找出每层的循环节,最外面的对1000000007取模,找最外层循环节222222224, 在对222222224取模, 找到次一层循环节183120,这样就可以通过三次快速幂求出结果了g(g(g(n)))%1000000007 = g(g(g(n)%183120)%222222224)%1000000007#include<stdio.h>#include<string.h>void m 阅读全文
posted @ 2012-09-17 00:21 'wind 阅读(300) 评论(0) 推荐(0)
摘要:Problem DescriptionThere are N cities in the country. Each city is represent by a matrix size of M*M. If city A, B and C satisfy that A*B = C, we say that there is a road from A to C with distance 1 (but that does not means there is a road from C to A).Now the king of the country wants to ask me som 阅读全文
posted @ 2012-04-01 16:38 'wind 阅读(447) 评论(0) 推荐(0)
摘要:DescriptionJiaoZhu likes going on adventure! One day, he walks into a big castle, and there is an unique stairway. JiaoZhu finds a board ,it says “The one who want to go upstairs only can go three steps the most once, meaning that you can go 1 or 2 or 3 steps once!”. Now, we have a problem, can you 阅读全文
posted @ 2012-03-16 07:38 'wind 阅读(210) 评论(0) 推荐(0)