KK's Steel

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)

Total Submission(s): 109    Accepted Submission(s): 48

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.
 
Source
 
Recommend
hujie   |   We have carefully selected several similar problems for you:  5624 5623 5622 5621 5619

#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(斐波那契数)的更多相关文章

  1. 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]. 即计算大斐波那契数再取模. 一开始看到大斐波那契数,就想到了矩阵 ...

  2. 斐波那契数[XDU1049]

    Problem 1049 - 斐波那契数 Time Limit: 1000MS   Memory Limit: 65536KB   Difficulty: Total Submit: 1673  Ac ...

  3. 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 …… ...

  4. Project Euler 104:Pandigital Fibonacci ends 两端为全数字的斐波那契数

    Pandigital Fibonacci ends The Fibonacci sequence is defined by the recurrence relation: F[n] = F[n-1 ...

  5. DP:斐波纳契数

    题目:输出第 n 个斐波纳契数(Fibonacci) 方法一.简单递归 这个就不说了,小n怡情,大n伤身啊……当n=40的时候,就明显感觉到卡了,不是一般的慢. //输出第n个 Fibonacci 数 ...

  6. HDU4549 M斐波那契数

    M斐波那契数列 题目分析: M斐波那契数列F[n]是一种整数数列,它的定义例如以下: F[0] = a F[1] = b F[n] = F[n-1] * F[n-2] ( n > 1 ) 如今给 ...

  7. HDU 5914 Triangle(打表——斐波那契数的应用)

    题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5914 Problem Description Mr. Frog has n sticks, whos ...

  8. [Swift]LeetCode509. 斐波那契数 | Fibonacci Number

    The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such th ...

  9. HDU 1021(斐波那契数与因子3 **)

    题意是说在给定的一种满足每一项等于前两项之和的数列中,判断第 n 项的数字是否为 3 的倍数. 斐波那契数在到第四十多位的时候就会超出 int 存储范围,但是题目问的是是否为 3 的倍数,也就是模 3 ...

  10. POJ 3070(求斐波那契数 矩阵快速幂)

    题意就是求第 n 个斐波那契数. 由于时间和内存限制,显然不能直接暴力解或者打表,想到用矩阵快速幂的做法. 代码如下: #include <cstdio> using namespace ...

随机推荐

  1. 【Oracle】恢复重做日志组

    我们在Oracle的日常运维中,有可能会遇到重做日志组丢失的情况.下面我将模拟丢失不同状态的日志组,并分别给出解决办法: 重做日志有以下几种状态,如下: -  CURRENT:此状态表示正在被 LGW ...

  2. C# 跨平台换行符 System.Environment.NewLine

    C# 跨平台换行符 System.Environment.NewLine

  3. Qt无法用UTF-8编辑问题

    原因: Windows默认编码格式是GBK. 而QT-各默认版本的编码格式是UTF-8. 解决方法": Windows环境下,Qt Creator,菜单->工具->选项-> ...

  4. 安卓Queue的使用

    Queue的成员函数        add        增加一个元索                     如果队列已满,则抛出一个IIIegaISlabEepeplian异常       rem ...

  5. 通用功能类:改变WinForm窗体显示颜色

    一.显示窗体调用方法 protected override void OnLoad(EventArgs e)        {            MDIClientSupport.SetBevel ...

  6. PAT_A1072#Gas Station

    Source: PAT A1072 Gas Station (30 分) Description: A gas station has to be built at such a location t ...

  7. GETDATE()

    定义和用法 GETDATE() 函数从 SQL Server 返回当前的时间和日期. 语法 GETDATE() 实例 例子 1 使用下面的 SELECT 语句: SELECT GETDATE() AS ...

  8. while(Thread.activeCount() > 1)

    今天看到深入理解JVM第367页多线程volatile部分照着书本敲着代码发现了一个问题 Thread.activeCount()会一直大于2 public class VolatileTest { ...

  9. Nginx Rewrite(伪静态)

    一.作用: 实现URL地址改写. 二.语法: 例:rewrite ^/(.*) http://bbs.wangguangtao.com/$1 permanent; 注:应用位置server.loeat ...

  10. 30.es增删改内部分发原理

    当客户端发送一次请求时,大致会经过以下几个步骤     (1)客户端发送一个请求过去,es的一个node接收到这个请求(随机的),这个node就被es内部分配成coordinating node(协调 ...