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. 【JSON类】使用说明

    理解键名路径 键名路径(keyPath)用于定位json的键,比如:{book: {title:”中国人”} },键名路径 book.title 表定位到book下的title键. 对于值是数组类型的 ...

  2. 缓存 memcache 小白笔记

    W: Memcached是神魔? Q:Memcached是一个自由开源的,高性能,分布式内存对象缓存系统. W:原理图 Q:如下 1浏览器    2 服务器   3  数据库    4  memcac ...

  3. Python爬虫模拟登录带验证码网站

    问题分析: 1.爬取网站时经常会遇到需要登录的问题,这是就需要用到模拟登录的相关方法.python提供了强大的url库,想做到这个并不难.这里以登录学校教务系统为例,做一个简单的例子. 2.首先得明白 ...

  4. 3.azkaban3.0测试

    测试目标 azkaban多executor下flow的分配方式 azkaban可以同时执行的flow\job个数 azkaban单个job最小使用的内存 相关配置 executor最大线程数: exe ...

  5. js经典试题之常用的方法

    js经典试题之常用的方法 1.下面代码输出的值 let s = "bob" const replaced = s.replace('b', 'l') replaced === &q ...

  6. Beta阶段项目展示博客

    Beta阶段项目展示 团队成员的简介 详细见团队简介 角色 姓名 照片 项目经理,策划 游心 策划 王子铭 策划 蔡帜 美工 赵晓宇 美工 王辰昱 开发.架构师 解小锐 开发 陈鑫 开发 李金奇 开发 ...

  7. 20145214 《Java程序设计》第4周学习总结

    20145214 <Java程序设计>第4周学习总结 教材学习内容总结 继承 继承基本上就是避免多个类间重复定义共同行为.要避免在程序设计上出现重复,可以把相同的程序代码提升为父类. 关键 ...

  8. lintcode-31-数组划分

    数组划分 给出一个整数数组 nums 和一个整数 k.划分数组(即移动数组 nums 中的元素),使得: 所有小于k的元素移到左边 所有大于等于k的元素移到右边 返回数组划分的位置,即数组中第一个位置 ...

  9. LintCode-66.二叉树的前序遍历

    二叉树的前序遍历 给出一棵二叉树,返回其节点值的前序遍历. 样例 给出一棵二叉树 {1,#,2,3}, 返回 [1,2,3]. 挑战 你能使用非递归实现么? 标签 递归 二叉树 二叉树遍历 非递归 c ...

  10. LintCode-12.带最小值操作的栈

    带最小值操作的栈 实现一个带有取最小值min方法的栈,min方法将返回当前栈中的最小值. 你实现的栈将支持push,pop 和 min 操作,所有操作要求都在O(1)时间内完成. 注意事项 如果堆栈中 ...