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
 
题意:
给你一个长度为N的钢管,问最多切成几个钢管,使得这些钢管不能围成三角形,并且不能有相同长度 !
思路:
要想使得钢管尽量多,那肯定从1开始吧,有了1,且不能重复,那肯定找2吧,而且三个钢管不能围成,三角形,那直接找a1 + a2 = a3的情况不就恰好不能围成三角形吗。所以很明显,这是一个a1 = 1,a2 = 2的斐波那契数列,找到第一个i  是的前i项和大于N,即可!特殊判断N = 1,N=2即可!他们都是1!
 
 #pragma comment(linker, "/STACK:1024000000,1024000000")
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<queue>
#include<set>
#include<bitset>
#include<map>
#include<vector>
#include<stdlib.h>
using namespace std;
#define ll long long
#define eps 1e-10
#define MOD 1000000007
#define N 1000000
#define inf 1e12
ll n;
ll f[N];
void init(){
f[]=;
f[]=;
for(ll i=;i<N;i++){
f[i]=f[i-]+f[i-];
}
}
int main()
{
init();
int t;
scanf("%d",&t);
while(t--){
scanf("%I64d",&n);
ll sum=;
ll i;
for(i=;i<N;i++){
sum+=f[i];
if(sum>n){
break;
}
}
if(n== || n==){
printf("1\n");
continue;
}
printf("%I64d\n",i-);
}
return ;
}
 
 
 
 
 
 
 
 
 
 
 
 

hdu 5620 KK's Steel(推理)的更多相关文章

  1. HDU 5620 KK's Steel (斐波那契序列)

    KK's Steel 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/J Description Our lovely KK ha ...

  2. HDU 5620 KK's Steel

    想了一下发现是斐波那契数列.....水题 #include <stdio.h> #include <algorithm> #include <string.h> # ...

  3. BestCoder Round #71 (div.2) (hdu 5620 菲波那切数列变形)

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

  4. hdu 5620

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

  5. hdu 5621 KK's Point(数学,推理题)

    题解: 在圆上点三个点时,除圆上三个交点外,圆内没有交点:在圆上点四个点时,除圆上四个交点外,圆内出现了一个交点,因此,在N个点中每四个点便可以在圆内产生一个交点,因此N个点在圆内形成的点的个数为CN ...

  6. HDU 4869 Turn the pokers(推理)

    HDU 4869 Turn the pokers 题目链接 题意:给定n个翻转扑克方式,每次方式相应能够选择当中xi张进行翻转.一共同拥有m张牌.问最后翻转之后的情况数 思路:对于每一些翻转,假设能确 ...

  7. HDU 4925 Apple Tree(推理)

    HDU 4925 Apple Tree 题目链接 题意:给一个m*n矩阵种树,每一个位置能够选择种树或者施肥,假设种上去的位置就不能施肥,假设施肥则能让周围果树产量乘2.问最大收益 思路:推理得到肯定 ...

  8. HDU 4923 Room and Moor(推理+栈维护)

    HDU 4924 Room and Moor 题目链接 题意:给定一个01组成的a序列.要求一个b序列,b序列每一个数值为[0, 1]之间的数,而且b序列为非递减序列,要求∑(ai−bi)2最小,求这 ...

  9. HDU 5623 KK's Number (博弈DP)

    KK's Number 题目链接: http://acm.hust.edu.cn/vjudge/contest/121332#problem/K Description Our lovely KK h ...

随机推荐

  1. 贝塞尔曲线:原理、自定义贝塞尔曲线View、使用!!!

    一.原理 转自:http://www.2cto.com/kf/201401/275838.html Android动画学习Demo(3) 沿着贝塞尔曲线移动的Property Animation Pr ...

  2. bzoj1644 [Usaco2007 Oct]Obstacle Course 障碍训练课

    Description 考虑一个 N x N (1 <= N <= 100)的有1个个方格组成的正方形牧场.有些方格是奶牛们不能踏上的,它们被标记为了'x'.例如下图: . . B x . ...

  3. (转)ZOJ 3687 The Review Plan I(禁为排列)

    The Review Plan I Time Limit: 5 Seconds      Memory Limit: 65536 KB Michael takes the Discrete Mathe ...

  4. canvas动画文字效果

    Doughnut Chartvar c=document.getElementById("canvas");var ctx=c.getContext("2d") ...

  5. sh_脚本语法

    介绍: 1 开头 程序必须以下面的行开始(必须方在文件的第一行): #!/bin/sh 符号#!用来告诉系统它后面的参数是用来执行该文件的程序.在这个例子中我们使用/bin/sh来执行程序. 当编写脚 ...

  6. javax.mail用smtp服务器发送带附件的邮件

    jar包: javax.mail-1.5.5.jar maven配置: <dependency> <groupId>com.sun.mail</groupId> & ...

  7. Linux转发性能评估与优化-转发瓶颈分析与解决方式(补遗)

    补遗 关于网络接收的软中断负载均衡,已经有了成熟的方案,可是该方案并不特别适合数据包转发,它对server的小包处理非常好.这就是RPS.我针对RPS做了一个patch.提升了其转发效率. 下面是我转 ...

  8. 【指数型母函数+非递归快速幂】【HDU2065】"红色病毒"问题

    大一上学完数分上后终于可以搞懂指数型母函数了.. 需要一点关于泰勒级数的高数知识 题目在此: "红色病毒"问题 Time Limit: 1000/1000 MS (Java/Oth ...

  9. MVC学习 (一)

    在学习MVC之前对asp.net MVC已经有了一些了解,但是还是有很多的疑问,接下来我慢慢来看书学习并带着问题写博客以作记录. 1.MVC是什么? 2.Asp.net MVC和传统的Asp.net ...

  10. nth-child和nth-of-type的区别

    以前一般都用:nth-child,后来知道了:nth-of-type,然后就一般用nth-of-type 它们两有什么区别呢? 首先来看个现象: 假如有这样一个HTML结构 <div class ...