AC代码:

#include<iostream>
using namespace std;
int a[][];
int d[][];
int t[][];
int temp[][]; void binary(int n)
{
int i,j,k;
while(n)
{
if(n%)
{
for(i=;i<=;i++)
for(j=;j<=;j++)
temp[i][j]=d[i][j];
for(i=;i<=;i++)
{
for(j=;j<=;j++)
{
int sum=;
for(k=;k<=;k++)
sum+=temp[i][k]*t[k][j];
d[i][j]=sum%;
}
}
}
n/=;
for(i=;i<=;i++)
for(j=;j<=;j++)
temp[i][j]=t[i][j];
for(i=;i<=;i++)
{
for(j=;j<=;j++)
{
int sum=;
for(k=;k<=;k++)
sum+=temp[i][k]*temp[k][j];
t[i][j]=sum%;
}
}
}
}
int main()
{
int n;
while(cin>>n,n+)
{
if(!n)
{
cout<<<<endl;
continue;
}
memset(a,,sizeof(a));
memset(d,,sizeof(a));
memset(t,,sizeof(a));
a[][]=a[][]=a[][]=;
d[][]=d[][]=;
t[][]=t[][]=t[][]=;
binary(n);
cout<<d[][]<<endl;
}
return ;
}

Nk 1430 Fibonacci(二分矩阵乘幂)的更多相关文章

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

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

  2. HDU:Gauss Fibonacci(矩阵快速幂+二分)

    http://acm.hdu.edu.cn/showproblem.php?pid=1588 Problem Description Without expecting, Angel replied ...

  3. hdu 3306 Another kind of Fibonacci(矩阵高速幂)

    Another kind of Fibonacci                                                        Time Limit: 3000/10 ...

  4. hdu 3117 Fibonacci Numbers 矩阵快速幂+公式

    斐波那契数列后四位可以用快速幂取模(模10000)算出.前四位要用公式推 HDU 3117 Fibonacci Numbers(矩阵快速幂+公式) f(n)=(((1+√5)/2)^n+((1-√5) ...

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

    Description Without expecting, Angel replied quickly.She says: "I'v heard that you'r a very cle ...

  6. 【POJ】3070 Fibonacci(矩阵乘法)

    http://poj.org/problem?id=3070 根据本题算矩阵,用快速幂即可. 裸题 #include <cstdio> #include <cstring> # ...

  7. hdu3306 Another kind of Fibonacci【矩阵快速幂】

    转载请注明出处:http://www.cnblogs.com/KirisameMarisa/p/4187670.html 题目链接:http://acm.hdu.edu.cn/showproblem. ...

  8. POJ 3070 Fibonacci 【矩阵快速幂】

    <题目链接> Description In the Fibonacci integer sequence, F0 = 0, F1 = 1, and Fn = Fn − 1 + Fn − 2 ...

  9. HDU 3117 Fibonacci Numbers(矩阵)

    Fibonacci Numbers [题目链接]Fibonacci Numbers [题目类型]矩阵 &题解: 后4位是矩阵快速幂求,前4位是用log加Fibonacci通项公式求,详见上一篇 ...

随机推荐

  1. VGG16学习笔记

    转载自:http://deanhan.com/2018/07/26/vgg16/ 摘要 本文对图片分类任务中经典的深度学习模型VGG16进行了简要介绍,分析了其结构,并讨论了其优缺点.调用Keras中 ...

  2. OpenCV2:介绍

    一.OpenCV简介 OpenCV所有的类和函数都在cv命名空间里面,可以用 using namespace cv; #include "opencv2/opencv.hpp" 1 ...

  3. 风格附加css

    #header #blogTitle { background: url("http://images.cnblogs.com/cnblogs_com/aiwuxia/1249780/o_1 ...

  4. quartz测试类

    package demo.mytest; import java.text.ParseException; import org.quartz.CronTrigger;import org.quart ...

  5. commons-logging 和log4j包下载 Spring根据XML配置文件生成对象

    需要用到Spring压缩包中的四个核心JAR包 beans .context.core 和expression 下载地址: https://pan.baidu.com/s/1qXLHzAW 以及日志j ...

  6. percona-server-5.7二进制安装(tokudb)

    1.下载二进制安装包(适用于红帽.centos) https://www.percona.com/downloads/Percona-Server-LATEST/Percona-Server-5.7. ...

  7. docker build no such file or directory

    在我构建新的镜像的时候, 发生 了  no such file or directory 的错误.  这个错误找了半天, 没头绪, 后来灵光一现, 原来是我的文件夹名字写错了 我的目录结构是这样的 [ ...

  8. 【php】 php.ini文件位置解析

    配置文件(php.ini)在 PHP 启动时被读取.对于服务器模块版本的 PHP,仅在 web 服务器启动时读取一次.对于CGI 和 CLI 版本,每次调用都会读取. php.ini 的搜索路径如下( ...

  9. Python模块目录

    阅读目录 模块 模块语法 常用模块 collections模块 time模块 random模块 os模块 sys模块 序列化模块 shelve模块 pickle模块 json模块 configpars ...

  10. poj--2139

    Description The cows have been making movies lately, so they are ready to play a variant of the famo ...