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. HDU4888 Redraw Beautiful Drawings(2014 Multi-University Training Contest 3)

    Redraw Beautiful Drawings Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Jav ...

  2. UVa 10601 (Polya计数 等价类计数) Cubes

    用6种颜色去染正方体的12条棱,但是每种颜色都都限制了使用次数. 要确定正方体的每一条棱,可以先选择6个面之一作为顶面,然后剩下的四个面选一个作为前面,共有24种. 所以正方体的置换群共有24个置换. ...

  3. UVa 11400 Lighting System Design

    题意: 一共有n种灯泡,不同种类的灯泡必须用不同种电源,但同一种灯泡可以用同一种电源.每种灯泡有四个参数: 电压值V.电源费用K.每个灯泡的费用C.所需该种灯泡的数量L 为了省钱,可以用电压高的灯泡来 ...

  4. 解决IE6下浮动层固定定位的经典方法

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  5. linux的HugePage与oracle amm关系

     如果Oracle 是11g以后的版本,那么默认创建的实例会使用Automatic Memory Management (AMM)的特性,该特性与HugePage不兼容. 在设置HugePage之前需 ...

  6. poj 3260 The Fewest Coins

    // 转载自http://blog.163.com/benz_/blog/static/18684203020115721917109/算法不难看出,就是一个无限背包+多重背包.问题在于背包的范围.设 ...

  7. 【Mysql】初学命令行指南

    MYSQL初学者使用指南与介绍 一.连接MYSQL 格式: mysql -h主机地址 -u用户名 -p用户密码 1.例1:连接到本机上的MYSQL. 首先在打开DOS窗口,然后进入目录 mysqlbi ...

  8. [Papers]NSE, $u_3$, Lebesgue space [Jia-Zhou, NARWA, 2014]

    $$\bex u_3\in L^\infty(0,T;L^\frac{10}{3}(\bbR^3)). \eex$$

  9. [Papers]NSE, $u_3$, Lebesgue space [Zhou-Pokorny, Nonlinearity, 2009]

    $$\bex u_3\in L^p(0,T;L^q(\bbR^3)),\quad \frac{2}{p}+\frac{3}{q}=\frac{3}{4}+\frac{1}{2q},\quad \fra ...

  10. Apache OFBiz 学习笔记 之 服务引擎 一

    概述     服务定义为一段独立的逻辑顺序,当多个服务组合一起时可完成不同类型的业务需求     服务有很多类型,WorkFlow.Rules.Java.SOAP.BeanShell等.java类型的 ...