HDU 1568 快速求斐波那契前四位
思路:
把斐波那契通项公式转化成log的形式,高中数学...
//By SiriusRen
#include <bits/stdc++.h>
using namespace std;
int f[],n;
int main(){
f[]=f[]=;
for(int i=;i<=;i++)f[i]=f[i-]+f[i-];
while(~scanf("%d",&n)){
if(n<=)printf("%d\n",f[n]);
else{
double s=log10(/sqrt())+n*log10((+sqrt())/),t;
s-=(int)s,t=pow(,s);
while(t<)t*=;
printf("%d\n",(int)t);
}
}
}
HDU 1568 快速求斐波那契前四位的更多相关文章
- SPOJ 5152 Brute-force Algorithm EXTREME && HDU 3221 Brute-force Algorithm 快速幂,快速求斐波那契数列,欧拉函数,同余 难度:1
5152. Brute-force Algorithm EXTREME Problem code: BFALG Please click here to download a PDF version ...
- 数学算法(一):快速求斐波那契数第n项通过黄金分割率公式
有一个固定的数学公式= =,不知道的话显然没法应用 首先黄金分割率接近于这个公式, (以下为黄金分割率与斐波那契的关系,可跳过) 通过斐波那契数列公式 两边同时除以 得: (1) 注意后一项比前一项接 ...
- HDU 1568 Fibonacci【求斐波那契数的前4位/递推式】
Fibonacci Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Proble ...
- codeforce 227E 矩阵快速幂求斐波那契+N个连续数求最大公约数+斐波那契数列的性质
E. Anniversary time limit per test2 seconds memory limit per test256 megabytes inputstandard input o ...
- hdu1568&&hdu3117 求斐波那契数前四位和后四位
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1568 题意:如标题所示,求斐波那契数前四位,不足四位直接输出答案 斐波那契数列通式: 当n<=2 ...
- 【poj3070】矩阵乘法求斐波那契数列
[题目描述] 我们知道斐波那契数列0 1 1 2 3 5 8 13…… 数列中的第i位为第i-1位和第i-2位的和(规定第0位为0,第一位为1). 求斐波那契数列中的第n位mod 10000的值. [ ...
- 数论+矩阵快速幂|斐波那契|2014年蓝桥杯A组9-fishers
标题:斐波那契 斐波那契数列大家都非常熟悉.它的定义是: f(x) = 1 .... (x=1,2) f(x) = f(x-1) + f(x-2) .... (x>2) 对于给定的整数 n 和 ...
- C# 求斐波那契数列的前10个数字 :1 1 2 3 5 8 13 21 34 55
//C# 求斐波那契数列的前10个数字 :1 1 2 3 5 8 13 21 34 55 using System; using System.Collections.Generic; using S ...
- 黑马入学基础测试(三)求斐波那契数列第n项,n<30,斐波那契数列前10项为 1,1,2,3,5,8,13,21,34,55
.获得用户的输入 计算 3打印就行了. 这里用到了java.util.Scanner 具体API 我就觉得不常用.解决问题就ok了.注意的是:他们按照流体的方式读取.而不是刻意反复 ...
随机推荐
- how to read openstack code: Core plugin and resource extension
本章我们将写一个自己的core plugin 和一个resource extension来加深理解.(阅读本文的前提是你已经理解了restful以及stevedore等内容) 什么是 core plu ...
- Material UI:很强大的CSS框架
Material UI 是一款功能很强大,界面却十分清新简洁的CSS框架.Material UI利用了Google的Material Design 全新设计语言.而且让每个UI组件都变得很独立.因此开 ...
- react-document-title
根据不同的路由改变文档的title 使用该组件: import ReactDocumentTitle from 'path/ReactDocumentTitle' render() { return ...
- web 开发之js---ajax 中的两种提交方式ajax post 和 ajax get 实例
()post http://04101334.iteye.com/blog/637695/ ()get function serializeElement(element) { var method ...
- 【iOS系列】-A server with the specified hostname could not be found.问题解决
[iOS系列]-A server with the specified hostname could not be found.问题解决 Reveal 在iOS开发中可以方便查看界面的布局,较为方便的 ...
- Part1-Redefining your data-access strategy 重新定义你的数据访问策略
欢迎来到Entity Framework 4 In Action,EF是微软3.5 SP1推出的ORM工具,现在已经更新到4.0版本(...)本书能确保你in a robust and model- ...
- vs2010中设置qt环境的智能识别方案
Qt搭建请参考:Win7系统VS2010下搭建qt开发环境 搭建好之后,虽然可以编译过去,但是写代码时,编辑器无法识别,也没有智能提示,并且代码中都是红色的提示如下: 此时需要设置一下include路 ...
- (22) java web的struts2框架的使用-struts配置文件
1,配置文件的引用 struts中配置文件可以有多个,每个模块的包里面都可以单独设立一个struts配置文件. 主的配置文件,放在“src”文件夹下,可以引入其他配置文件,引入方式: <!-- ...
- Adding Security to an Existing Website
The procedure earlier in this article relies on using the Starter Site template as the basis for web ...
- mysql10---索引优化
D:\MYSQL\mysql-winx64\data\WIN-20171216YUR-slow.log是慢日志: ; ; # Time: :.472000Z # # Query_time: Rows_ ...