标签:
一个 数列,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