KK's Steel

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

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米长的钢管切成若干段 要求每段 长度不同 且任意三段不能组成三角形 问最多能分成多少段
题解: 易发现 满足斐波那契数列
 
  

#include<iostream>
#include<cstdio>
#define LL __int64
using namespace std;
int main()
{
int t;
LL n;
scanf("%d",&t);
for(int i=1;i<=t;i++)
{
scanf("%I64d",&n);
LL exm=1;
LL ans=0;
LL flag=1;
while(n>=exm)
{
LL gg;
gg=exm;
ans++;
n-=exm;
exm+=flag;
flag=gg;
//cout<<flag<<" "<<exm<<endl;
}
printf("%I64d\n",ans);
}
return 0;
}

  

hdu 5620的更多相关文章

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

  3. hdu 5620 KK's Steel(推理)

    Problem Description Our lovely KK has a difficult mathematical problem:he has a N(1≤N≤1018) meters s ...

  4. HDU 5620 KK's Steel

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

  5. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  6. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  7. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  8. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  9. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

随机推荐

  1. linux学习总结---mysql总结②

    函数: 字符串 日期时间 数学 子查询:嵌套查询 1. 做子查询: select sclass from studb where sname='..' 2.select * from studb wh ...

  2. 100. Remove Duplicates from Sorted Array && 101. Remove Duplicates from Sorted Array II [easy]

    这两题类似,所以放在一起,先看第一题: Description Given a sorted array, remove the duplicates in place such that each ...

  3. 从零开始的Python学习Episode 5——字典

    字典 字典是另一种可变容器模型,且可存储任意类型对象. 一.添加 (1)直接添加 dict={'name':'smilepup'} dict['age']=20 dict['name']='piggy ...

  4. C++复合类型(结构,共用体,枚举)

    •结构是用户定义的类型,而结构的声明定义了这种类型的数据属性. 一.关键字struct声明:   定义了一种新类型 struct inflatable{ char name[20];//结构成员 fl ...

  5. kaldi - Online Audio Server(服务器客户端建立方法-旧版在线解码)

    目录 一.服务器客户端识别系统建立方法 1. Command line to start the server(服务器端启动方式): 2. Command line to start the clie ...

  6. python 智能合约日志操作

    from __future__ import unicode_literals import json from time import sleep, time # 中文编码 def encode_s ...

  7. SpringCloud IDEA 教学 (二) Eureka Service

    写在开头 本篇继续介绍基于Eureka的SpringCloud微服务搭建,回顾一下搭建过程, 第一步:建立一个服务注册中心: 第二步:建立微服务并注入到注册中心: 第三步:建立client端来访问微服 ...

  8. Linux中常用的关机和重新启动命令

    hutdown.halt.reboot以及init,它们都可以达到关机和重新启动的目的,但是每个命令的内部工作过程是不同的,下面将逐一进行介绍. 一.shutdown shutdown命令用于安全关闭 ...

  9. Thinkphp实现excel导出数据

    前端: 点击导出触发click事件,传值export指令和args关键字(args是指我们是否有查询取哪些数据)到控制器 $(document).on("click", " ...

  10. 你代码写得这么丑,一定是因为你长得不好看----panboo第一篇博客

    一.个人介绍 我叫潘博,软嵌162,学号1613072055. 以“panboo”名称混迹于各大开源IT论坛与博客. 除了编程,我的最大爱好是篮球与健身,热衷于各种IT技术与运动. 我做过的软件项目有 ...