码迷,mamicode.com
首页 > 其他好文 > 详细

矩阵构造

时间:2015-06-09 16:13:17      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

一个  数列,a[1]=1,给出a[2],            a[n]=2*a[2]*a[n-1]-a[n-2],求这个数列的平方和模M

数据范围:1<=a[2],M<=1000000000(9次方),2<=N<=1000000000(9次方)

思路:

一看 n的范围是9次方只能想log的算法(构造矩阵,二分幂)

最后构造的结果是

(s[n]代表的是前n项的和)

a[n],a[n-1]*a[n-1],a[n-1]*a[n-2],s[n-1]              2*a[2]*a[2]          1          0              1

                                                                      1-4*a[2]*a[2]          0        2*a[2]        0

                                                                               4*a[2]            0        -1               0

                                                                                0                   0          0              1

 

构造的过程

s[n]=s[n-1]+a[n]*a[n]

a[n]+2*a[2]*2*a[2]*a[n-1]*a[n-1]+a[n-2]*a[n-2]-2*2*a[2]*a[n-1]*a[n-2]

2*2*a[2]*a[n]*a[n-1]=2*2*a[2]*2*a[2]*a[n-1]*a[n-1]-2*2*a[n-1]*a[n-2]

 

矩阵构造

标签:

原文地址:http://www.cnblogs.com/ACWQYYY/p/4563447.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!