KK's Steel

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 350    Accepted Submission(s): 166

Problem Description
Our lovely KK has a difficult mathematical problem:he has a 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.
 
Input
The first line of the input file contains an integer 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.

 
Output
For each test case, output one line, an integer represent the maxiumum number of steels he can cut it into.
 
Sample Input
1
6
 
Sample Output
3

Hint

1+2+3=6 but 1+2=3 They are all different and cannot make a triangle.

 
要求:给一个长整形数n让你把n分成若干份,1、任意两份长度不能相等 2、任意三分不能组成三角形
 
分析:因为斐波那契数列中的数满足此要求,所以从这个方面入手,只要分成的数满足a+b<=c即可,所以我们在数列1  2  3  5  8  13  21 ......的数中选取,如果前i项的和等于n输出i如果前i项的和大于n输出i-1
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<algorithm>
#define MAX 100100
#define INF 0x3f3f3f
#define LL long long
using namespace std;
LL fb[10010];
LL f[1001];
void biao()
{
LL i,j;
fb[1]=1;
fb[2]=2;
for(i=3;i<120;i++)
fb[i]=fb[i-1]+fb[i-2];
f[1]=fb[1];
for(i=2;i<120;i++)
f[i]=f[i-1]+fb[i];
}
int main()
{
int t,i,j;
LL n;
biao();
scanf("%d",&t);
while(t--)
{
scanf("%lld",&n);
for(i=1;i<120;i++)
{
if(n==f[i])
{
printf("%d\n",i);
break;
}
if(n<f[i])
{
printf("%d\n",i-1);
break;
}
}
}
return 0;
}

  

BestCoder Round #71 (div.2) (hdu 5620 菲波那切数列变形)的更多相关文章

  1. 菲波那切数列(Fibonacci Number)

    什么是菲波那切数列?自己google一下,面试题里面经常遇到,考试递归算法用的. 在菲波那切数列中用递归不太好.第三种算法最好. 第一 递归算法最差了,不想说.测试一下,当N=6000时,半天出不来数 ...

  2. BestCoder Round #71 (div.2) (hdu 5621)

    KK's Point Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total ...

  3. BestCoder Round #71 (div.2)

    数学 1001 KK's Steel 类似斐波那契求和 #include <cstdio> #include <cstring> #include <algorithm& ...

  4. BestCoder Round #52 (div.2) HDU 5418 Victor and World (DP+状态压缩)

    [题目链接]:pid=5418">click here~~ [题目大意]: 问题描写叙述 经过多年的努力,Victor最终考到了飞行驾照. 为了庆祝这件事,他决定给自己买一架飞机然后环 ...

  5. php实现菲波那切数列和杨辉三角

    1.递归  显示斐波那契数列 <?PHP         function recursion($num){               //判断是否小于0               if($ ...

  6. hdu 5636 搜索 BestCoder Round #74 (div.2)

    Shortest Path  Accepts: 40  Submissions: 610  Time Limit: 4000/2000 MS (Java/Others)  Memory Limit: ...

  7. BestCoder Round #69 (div.2) Baby Ming and Weight lifting(hdu 5610)

    Baby Ming and Weight lifting Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K ( ...

  8. BestCoder Round #68 (div.2) tree(hdu 5606)

    tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submis ...

  9. hdu5634 BestCoder Round #73 (div.1)

    Rikka with Phi  Accepts: 5  Submissions: 66  Time Limit: 16000/8000 MS (Java/Others)  Memory Limit: ...

随机推荐

  1. C#计算程序执行速度

    long t1 = DateTime.Now.Ticks; //执行程序,例如处理100个文件 long t2 = DateTime.Now.Ticks; Response.Write("执 ...

  2. objective-c里的方法指针IMP的用法

    SGPopSelectView.h @interface SGPopSelectView : UIView @property (nonatomic, assign) SEL selector; @p ...

  3. 服务器安装Apache+Tomcat+Memcached共享Session的构架设计

    网站集群部署解决计划 一.       计划目标 实现互动留言系统.后台发布系统的高可用性,有效解决高并发量对单台应用服务器的打击,确保应用服务器单点故障不影响系统正常运行. 二.       部署架 ...

  4. 【转】移动web资源整理

    目录(更新于20150311) meta基础知识 H5页面窗口自动调整到设备宽度,并禁止用户缩放页面 忽略将页面中的数字识别为电话号码 忽略Android平台中对邮箱地址的识别 当网站添加到主屏幕快速 ...

  5. Delphi or函数的用法

    function GetFlag(a: string): Integer;var I: Integer;begin Result := 0; for I := 0 to 3 - 1 do begin ...

  6. [转] GIS二次开发(C#+AE)

    乘风莫邪 原文GIS二次开发(C#+AE) 此过程描述了使用ArcGIS控件建立和部署应用的方法和步骤. 你可以在下面的目录下找到相应的样例程序: <</FONT>安装目录>/ ...

  7. [Papers]MHD, $\pi$, Lorentz space [Suzuki, DCDSA, 2011]

    $$\bex \sen{\pi}_{L^{s,\infty}(0,T;L^{q,\infty}(\bbR^3))} +\sen{{\bf b}}_{L^{\gamma,\infty}(0,T;L^{\ ...

  8. 转载:Hadoop权威指南学习笔记

    转自:http://pieux.github.io/blog/2013-05-08-learn-hadoop-the-definitive-guide.html 1 前言 Hadoop的内部工作机制: ...

  9. 《Python CookBook2》 第一章 文本 - 每次处理一个字符 && 字符和字符值之间的转换

    文本 - 总结: 什么是文本Python 中的string 类型是不可变类型.文本,一个字符的矩阵,每一个单独的文本快可以被缩进和组织起来. 基本的文本操作①解析数据并将数据放入程序内部的结构中:②将 ...

  10. Android应用启动时间及启动日志获取方法

    1. Android应用中,可以使用如下方式进行应用启动时间的查看 2. 启动日志获取方法: