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. VMware SDK使用指南

    刚开始用VMware官方推荐的SDK,真的是又臭又长,代码结构不清晰,易读性差.后来VMware的同学给推荐了一款开源的SDK,一上手感觉工作效率提高了100倍!推荐大家使用~. 该SDK对VMwar ...

  2. JAVA 面试须知

    本篇文章会对面试中常遇到的Java技术点进行全面深入的总结,帮助我们在面试中更加得心应手,不参加面试的同学也能够借此机会梳理一下自己的知识体系,进行查漏补缺. 1. Java中的原始数据类型都有哪些, ...

  3. JavaScript 正则

    元字符 预定义类 边界 ^在中括号中时,匹配非hello的 str = 'hello world' str.match(/[^hello]/g) //[" ", "w&q ...

  4. 加密SecurityHelper

    接下来给大家分享一下我用的加密helper,现在只用的md5加密的方法,网上很多方法找到的时候加密完了会变成乱码,这样对于密码这种字段保存的时候就会出错.其实只需要把加密完的byte字节转化成16位就 ...

  5. LeetCode - 463. Island Perimeter - O(MN)- (C++) - 解题报告

    原题 原题链接 You are given a map in form of a two-dimensional integer grid where 1 represents land and 0 ...

  6. SpringCloud IDEA 教学 番外篇 后台运行Eureka服务注册中心

    写在开头 研发过程中经常要做的事就是启动Eureka服务注册中心,每每都要启动一个IDEA,很是困扰.现在分享一个后台启动服务注册中心的方法. 准备工作 1打包一个eureka服务注册中心jar包(注 ...

  7. ThinkPHP - 2 - SAE(新浪云)部署

    ThinkPHP3.2核心内置了对SAE平台的支持(采用了应用模式的方式),具有自己的独创特性,能够最大程度的使用ThinkPHP的标准特性,让开发人员感受不到SAE和普通环境的差别.甚至可以不学习任 ...

  8. [ML] the notes

    "Machine Learning is not who has the best algorithm that wins. It is who has the most data.&quo ...

  9. WPF+数据库+三层

    1.计算类 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespac ...

  10. 福大软工1816:Alpha(7/10)

    Alpha 冲刺 (7/10) 队名:Jarvis For Chat 组长博客链接 本次作业链接 团队部分 团队燃尽图 工作情况汇报 张扬(组长) 过去两天完成了哪些任务: 文字/口头描述: 1.完成 ...