hd 5620 KK's Steel(斐波那契数列)
来源:互联网 发布:matlab7,1如何进入编程 编辑:程序博客网 时间:2024/05/22 14:13
KK's Steel
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1009 Accepted Submission(s): 487
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 integerN(1≤N≤1018) ,indicating the length of the steel.
Each test case contains one line including a integer
Output
For each test case, output one line, an integer represent the maxiumum number of steels he can cut it into.
Sample Input
16
Sample Output
3Hint1+2+3=6 but 1+2=3 They are all different and cannot make a triangle.题意:给你一根长为n的木棒,怎你最多能把它分成多少段,并且要求任意两段长度不相等,任意三段不能组成三角形思路:通过观察,只能分成 1 2 3 5 8 13 21 .......... 即斐波那契数列#include<cstdio>#define LL long long intint main(){ int t; LL n;LL f[100]; f[1] = 1; f[2] = 2; for(int i = 3 ; i <= 85 ; i++) { f[i] = f[i-1] + f[i-2]; } scanf("%d",&t); while(t--) { LL sum = 0; int falg = 0;- scanf("%I64d",&n); for(int i = 1 ; i <= 85 ; i++){ sum += f[i]; if(sum >= n) { falg = i; break; } } if(sum != n) falg--; printf("%d\n",falg); } return 0;}
0 0
- hd 5620 KK's Steel(斐波那契数列)
- HDOJ 5620-KK's Steel【斐波那契数列】
- HDU 5620 KK's Steel(斐波那契数列的巧妙应用)
- HDU 5620 KK's Steel(找规律,斐波那契数列的应用)
- HDU 5620 KK's Steel 斐波那契
- 【斐波那契应用】HDOJ KK's Steel 5620
- BestCoder Round #71 (div.2)-KK's Steel(斐波那契数列)
- hdu KK's Steel【思维】【斐波那契数列应用】
- hdoj--5620--KK's Steel(斐波那契数)
- KK's Steel bestcoder round 71 hdu 5620(裴波那契)
- KK's Steel<hdoj5620>菲波那切数列的应用
- HDU 5620 KK's Steel(水~)
- hdoj 5620 KK's Steel (数学思维,那波婓切)
- HDU 5620 KK's Steel
- HDU 5620 KK's Steel
- hdoj-5620-KK's Steel
- HDU 5620 KK's Steel(简单的推理题)
- 【杭电oj】5620 - KK's Steel(递推)
- cocos2dx_lesson1_环境搭建
- iOS-69-WKWebview用法与UIWebview对比(附demo、PPT)
- 13 为什么会有泛型?
- 【计算机网络-1】【第一章】计算机网络体系结构
- MyBatis学习总结(一)——MyBatis快速入门
- hd 5620 KK's Steel(斐波那契数列)
- Android初级教程:如何自定义一个状态选择器
- 多线程、网络总结
- 将char转换成wchar_t, 获取中文字符串的任意汉字元素
- pat 1038. Recover the Smallest Number (30)
- HDU 1729 Stone Game(思维 & SG函数)
- 指针和指针所指的对象改变的问题
- 使用第三方插件Curvy为unity场景快速生成运动轨迹与赛道
- HDU/HDOJ 2546 饭卡(DP,0/1背包)