zoukankan
html css js c++ java
HDU2855 Fibonacci Checkup 矩阵的应用
/* 两个数论公式: f(k) = ( (1+sqrt(5)) / 2 ) ^ k - ( (1-sqrt(5)) / 2) ^ k (1+a)^n = Sum(C(k|n) * (a^k)) 推导过程: Sum(C(k|n) * f(k)) = Sum(C(k|n) * ( (1+sqrt(5)) / 2 ) ^ k - ( (1-sqrt(5)) / 2) ^ k) = Sum(C(k|n) * (1+sqrt(5)) / 2 ) ^ k) - Sum(C(k|n) * (1-sqrt(5)) / 2 ) ^ k) = ( (3+sqrt(5)) / 2 ) ^ k - ( (3-sqrt(5)) / 2) ^ k = ( (1+sqrt(5)) / 2 ) ^ 2k - ( (1-sqrt(5)) / 2) ^ 2k = f(2k) 构造矩阵是浮云 Fn(1,2) = |f(n) f(n-1)| F1(1,2) = |f(1) f(1)| = |1 0| A(2,2) = |1 1| |1 0| */ #include "Mat.h" #include <iostream> using namespace std; int main() { Mat A(2,2),F(1,2); int t, n; scanf("%d", &t); while(t--) { scanf("%d%d", &n, &mod); if(n == 0) { printf("0\n"); continue; } A.clear(2);A.s[1][1] = 0; F.clear(1); A.Er_work(n*2-1); F.Multiply(A); printf("%d\n", F.s[0][0]); } return 0; }
查看全文
相关阅读:
c++智能指针-shared_ptr
python全栈学习笔记(二)网络基础之子网划分
python全栈学习笔记(一)网络基础之网络协议篇
Fiddler抓包4-工具介绍(request和response)
python接口自动化5-Json数据处理
python接口自动化4-绕过验证码登录(cookie) (转载)
Http status(二)
python接口自动化1-发送get请求
Fiddler抓包11-HTTPS证书Actions无法导出问题
使用idea配置tomcat将web项目跑起来
原文地址:https://www.cnblogs.com/windmissing/p/2559892.html
最新文章
Zend_Application 流程详解
ubuntu下无法启动vivado SDK的解决办法(一)
lattice_ddr3调试经验分享(三)DDR速率计算
ddr3调试经验分享(五)——KC705_MIG时钟清单
lattice_ddr3调试经验分享(二)官方testbench分析
HDMI调试经验分享(一)—— 基于KC705的example实现
ddr3调试经验分享(四)——KC705_MIG_axi接口
lattice_ddr3调试经验分享(一)建立工程与仿真
ddr3调试经验分享(三)——KC705_MIG_app接口设计
Lattice Diamond调用modelsim仿真注意事项
热门文章
ddr3调试经验分享(二)——KC705上的ddr3初始化不成功
c++11 stl-array
c++ stl框架基本知识
c++ keyword实例
c++11中新型for循环,auto, 类成员的初始化及左右值引用
c++ lambda函数的真实面目
c++ smart_ptr 总结
c++智能指针-unique_ptr
c++ shared_ptr储存this指针多次析构问题之enable_shared_from_this解决方案
c++智能指针-shared_ptr的尴尬-诞生weak_ptr
Copyright © 2011-2022 走看看