这题自己一开始硬是不会处理√6 前面的系数,直到看了别人的博客后才知道是怎么解得,不多说,先付上一张图:

  推出这个关系后,就很容易了。

 #include<cstdio>
#include<cstring>
typedef long long LL;
const int mod= ; struct matrix{
int a,b,c,d;
matrix(int a=, int b=, int c=, int d=):a(a),b(b),c(c),d(d) {}
matrix operator *(const matrix &m2){
return matrix((a*m2.a%mod+b*m2.c%mod)%mod, (a*m2.b%mod+b*m2.d%mod)%mod, (c*m2.a%mod+d*m2.c%mod)%mod, (c*m2.b%mod+d*m2.d%mod)%mod);
}
} M(,,,),E(,,,); matrix quick_mod(matrix m, int b){
matrix res(E);
while(b){
if(b&) res= res*m;
m= m*m;
b>>=;
}
return res;
} void solve(){
int n;
scanf("%d",&n);
if(n==) { puts(""); return ; }
matrix tmp= quick_mod(M,n-);
int xn= (tmp.a*%mod+tmp.b*%mod)%mod;
printf("%d\n",(*xn-)%mod);
} int main(){
int t;
scanf("%d",&t);
while(t--) solve();
return ;
}

hdu 2256 好神奇的矩阵!的更多相关文章

  1. HDU 2256 Problem of Precision(矩阵高速幂)

    题目地址:HDU 2256 思路: (sqrt(2)+sqrt(3))^2*n=(5+2*sqrt(6))^n; 这时要注意到(5+2*sqrt(6))^n总能够表示成an+bn*sqrt(6); a ...

  2. HDU 2256 Problem of Precision (矩阵快速幂)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2256 最重要的是构建递推式,下面的图是盗来的.貌似这种叫共轭数. #include <iostr ...

  3. HDU 2256 Problem of Precision(矩阵)

    Problem of Precision [题目链接]Problem of Precision [题目类型]矩阵 &题解: 参考:点这里 这题做的好玄啊,最后要添加一项,之后约等于,但是有do ...

  4. hdu 2256 Problem of Precision

    点击打开hdu 2256 思路: 矩阵快速幂 分析: 1 题目要求的是(sqrt(2)+sqrt(3))^2n %1024向下取整的值 3 这里很多人会直接认为结果等于(an+bn*sqrt(6))% ...

  5. bzoj2396: 神奇的矩阵

    与51nod1140一样.不过这题是多组数据的...坑.... #include<cstdio> #include<cstring> #include<cctype> ...

  6. [Swust OJ 1126]--神奇的矩阵(BFS,预处理,打表)

    题目链接:http://acm.swust.edu.cn/problem/1126/ Time limit(ms): 1000 Memory limit(kb): 65535 上一周里,患有XX症的哈 ...

  7. 神奇的矩阵 NOI模拟题

    神奇的矩阵 题目大意 有一个矩阵\(A\),第一行是给出的,接下来第\(x\)行,第\(y\)个元素的值为数字\(A_{x-1,y}\)在\(\{A_{x-1,1},A_{x-1,2},A_{x-1, ...

  8. hdu 5667 BestCoder Round #80 矩阵快速幂

    Sequence  Accepts: 59  Submissions: 650  Time Limit: 2000/1000 MS (Java/Others)  Memory Limit: 65536 ...

  9. HDU 1588 Gauss Fibonacci(矩阵高速幂+二分等比序列求和)

    HDU 1588 Gauss Fibonacci(矩阵高速幂+二分等比序列求和) ACM 题目地址:HDU 1588 Gauss Fibonacci 题意:  g(i)=k*i+b;i为变量.  给出 ...

随机推荐

  1. SDUT 2413:n a^o7 !

    n a^o7 ! Time Limit: 1000MS Memory limit: 65536K 题目描述 All brave and intelligent fighters, next you w ...

  2. Antenna Placement

    Antenna Placement Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7574 Accepted: 3762 Des ...

  3. Java fundamentals of basic IO

    IO is a problem difficult to handle in various of systems because it  always becomes a bottleneck in ...

  4. hnu Dirichlet's Theorem

    /* 求ax+b x属于区间[L,R];范围内素数的个数. a*R+b<=10^12 ; R-L+1<=10^6 枚举,超时. 1.如果GCD(a,b)>1 那么a+b 2*a+b ...

  5. easyui.combotree.search.js

    (function ($) { //combotree可编辑,自定义模糊查询 $.fn.combotree.defaults.editable = true; $.extend($.fn.combot ...

  6. SQL高级查询——50句查询(含答案)

    -一个题目涉及到的50个Sql语句 --(下面表的结构以给出,自己在数据库中建立表.并且添加相应的数据,数据要全面些. 其中Student表中,SId为学生的ID) ----------------- ...

  7. Struts2框架的运行流程

    Struts2的运行流程 1.浏览器发送请求到控制器(如Struts2中的核心控制器StrutsPrepareAndExecuteFilter): 2.控制器调用Action的execute方法: 3 ...

  8. Bootstrap_基本HTML模板

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8&quo ...

  9. BZOJ 3085: 反质数加强版SAPGAP (反素数搜索)

    题目链接:http://www.lydsy.com:808/JudgeOnline/problem.php?id=3085 题意:求n(<=10^100)之内最大的反素数. 思路: 优化2: i ...

  10. Java Web表达式注入

    原文:http://netsecurity.51cto.com/art/201407/444548.htm 0×00 引言 在2014年6月18日@终极修炼师曾发布这样一条微博: 链接的内容是一个名为 ...