设为首页 加入收藏

TOP

POJ 3070 Fibonacci (矩阵)
2015-07-24 06:28:53 来源: 作者: 【 】 浏览:34
Tags:POJ 3070 Fibonacci 矩阵


构造矩阵

0 1 * a = b

1 1 b a+b


然后快速幂


也可以按照题目所给的直接快速幂


#include 
  
   
#include 
   
     #include 
    
      #include 
     
       #include 
      
        #define N 30 using namespace std; const int mod = 10000; struct matrix { int a[2][2]; }origin; int n=2,m; matrix multiply(matrix x,matrix y) { matrix temp; memset(temp.a,0,sizeof(temp.a)); for(int i=0;i
       
        >=1; A=multiply(A,A); } return res; } void print(matrix x) { for(int i=0;i
        
         

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇nyoj 37 回文字符串 [DP] 下一篇XTU OJ 1207 Welcome to XTCPC (..

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: