hdoj--5620--KK's Steel(斐波那契数)
KK's Steel
Total Submission(s): 109 Accepted Submission(s): 48
N(1≤N≤1018)
meters steel,he will cut it into steels as many as possible,and he doesn't want any two of them be the same length or any three of them can form a triangle.
T(1≤T≤10),
which indicates the number of test cases.
Each test case contains one line including a integer
N(1≤N≤1018),indicating
the length of the steel.
1
6
3Hint1+2+3=6 but 1+2=3 They are all different and cannot make a triangle.
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
__int64 f[1000];
__int64 n;
int main()
{
int t;
scanf("%d",&t);
f[0]=1;
f[1]=1;
for(int i=2;i<=100;i++)
f[i]=f[i-1]+f[i-2];
while(t--)
{
cin>>n;
__int64 ans=1;
while(n)
{
n-=f[ans];
// printf("%d %d\n",n,f[ans]);
if(n<f[ans+1]) break;
ans++;
}
cout<<ans<<endl;
}
return 0;
}
hdoj--5620--KK's Steel(斐波那契数)的更多相关文章
- UVA 11582 Colossal Fibonacci Numbers! 大斐波那契数
大致题意:输入两个非负整数a,b和正整数n.计算f(a^b)%n.其中f[0]=f[1]=1, f[i+2]=f[i+1]+f[i]. 即计算大斐波那契数再取模. 一开始看到大斐波那契数,就想到了矩阵 ...
- 斐波那契数[XDU1049]
Problem 1049 - 斐波那契数 Time Limit: 1000MS Memory Limit: 65536KB Difficulty: Total Submit: 1673 Ac ...
- C++求斐波那契数
题目内容:斐波那契数定义为:f(0)=0,f(1)=1,f(n)=f(n-1)+f(n-2)(n>1且n为整数) 如果写出菲氏数列,则应该是: 0 1 1 2 3 5 8 13 21 34 …… ...
- Project Euler 104:Pandigital Fibonacci ends 两端为全数字的斐波那契数
Pandigital Fibonacci ends The Fibonacci sequence is defined by the recurrence relation: F[n] = F[n-1 ...
- DP:斐波纳契数
题目:输出第 n 个斐波纳契数(Fibonacci) 方法一.简单递归 这个就不说了,小n怡情,大n伤身啊……当n=40的时候,就明显感觉到卡了,不是一般的慢. //输出第n个 Fibonacci 数 ...
- HDU4549 M斐波那契数
M斐波那契数列 题目分析: M斐波那契数列F[n]是一种整数数列,它的定义例如以下: F[0] = a F[1] = b F[n] = F[n-1] * F[n-2] ( n > 1 ) 如今给 ...
- HDU 5914 Triangle(打表——斐波那契数的应用)
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Problem Description Mr. Frog has n sticks, whos ...
- [Swift]LeetCode509. 斐波那契数 | Fibonacci Number
The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such th ...
- HDU 1021(斐波那契数与因子3 **)
题意是说在给定的一种满足每一项等于前两项之和的数列中,判断第 n 项的数字是否为 3 的倍数. 斐波那契数在到第四十多位的时候就会超出 int 存储范围,但是题目问的是是否为 3 的倍数,也就是模 3 ...
- POJ 3070(求斐波那契数 矩阵快速幂)
题意就是求第 n 个斐波那契数. 由于时间和内存限制,显然不能直接暴力解或者打表,想到用矩阵快速幂的做法. 代码如下: #include <cstdio> using namespace ...
随机推荐
- Excel常用的小技巧
1.Excel如何实现单元格内轻松换行:按住ALT+enter就可以了. 2.Excel固定表头:在“视图”>冻结窗口>冻结首行. 3.防止电脑突然断电,导致正在编辑的Excel数据丢失, ...
- py2exe打包遇到的问题
py2exe打包python成.exe文件 打包过程和结果 1.创建setup脚本打包文件,其中设置打包的属性和方法.注意:尽量将被打包文件和此打包脚本放在同目录下(因为在尝试非同目录下时,出现了非可 ...
- sql server 还原数据库,数据库提示正在还原中的处理办法
还原数据库时,提示还原成功,可是数据库列表中该数据库显示正在还原中: 执行此命令即可: RESTORE DATABASE EnterPriseBuilding WITH RECOVERY 了解SQ ...
- 微信公众号API使用总结
官网: https://mp.weixin.qq.com/ API: http://mp.weixin.qq.com/wiki/home/index.html 接口调试工具:h ...
- 三维重建:SLAM相关的一些术语解释
SLAM是一个工程问题,再次复习一下工程中可能用到的名词解释. 还是不要看了,高翔的科普读物已经出版了,读他的<slam十四讲>就可以了. 一.度量相关: 世界坐标系:描述图像的平面坐标系 ...
- 【sqli-labs】 less36 GET- Bypass MYSQL_real_escape_string (GET型绕过MYSQL_real_escape_string的注入)
看一下mysql_real_escape_string()函数 \x00 \x1a 注入的关键还是在于闭合引号,同样使用宽字节注入 http://192.168.136.128/sqli-labs-m ...
- 学习Spider 了解 Scrapy的流程
Scrapy 先创建项目 在windows下 scrapy startproject myproject #myproject是你的项目名称 cd 项目名称 scrapy g ...
- Markdown 常用语法总结
注意:Markdown使用#.+.*等符号来标记,符号后面必须跟上至少跟上 1个空格才有效! Markdown的常用语法 标题 Markdown标题支持两种形式. 1.用#标记 在标题开头加上1~6个 ...
- ext4的一些特性
delalloc介绍 delalloc是ext4下的一个新特性,延迟分配技术Delay Allocation. 实现原理为: Buffer Write时数据会被保存到page cache中,但是系统并 ...
- 安装 Ubuntu 14.04 之后要做的一些事
转自: http://www.cnblogs.com/marcowei/p/3841342.html 安装 ubuntu14.04 之后要做的一些事 前言: 用 ubuntu14.04 也有一段时间 ...