hdoj5620KK's Steel
来源:互联网 发布:游族网络有哪些游戏 编辑:程序博客网 时间:2024/06/11 05:55
KK's Steel
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 20 Accepted Submission(s): 13
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.
#include<cstdio>#include<cstdlib>#include<cstring>#include<algorithm>#include<cmath>#include<list>#include<queue>#include<vector>using namespace std;const int maxn=10010;long long num[maxn];void init(){ num[1]=1;num[2]=1;num[3]=2; for(int i=4;i<100;++i){ num[i]=num[i-1]+num[i-2]; }}int main(){ init(); int t,i,j,k; long long n; scanf("%d",&t); while(t--){ scanf("%I64d",&n); long long ans=0; for(i=2;;++i){ ans+=num[i]; if(ans>=n)break; } if(ans==n){ printf("%d\n",i-1); } else { printf("%d\n",i-2); } } return 0;}
0 0
- hdoj5620KK's Steel
- hdu_5620_KK's Steel(水题)
- HDU 5620 KK's Steel
- HDU 5620 KK's Steel
- hdoj-5620-KK's Steel
- hdoj 5620 KK's Steel 【数学】
- hdoj KK's Steel 5620 (打表)
- 杭电5620 KK's Steel
- HDU5620 KK's Steel(C语言版)
- HDU5620 KK's Steel(C++语言版)
- HDU 5620 KK's Steel <贪心思维>
- HDU 5620 KK's Steel(水~)
- BestCoder Round #71 (div.2)1001KK's Steel
- HDU 5620 KK's Steel(简单的推理题)
- HDU 5620 KK's Steel 斐波那契
- 【斐波那契应用】HDOJ KK's Steel 5620
- HDOJ 5620-KK's Steel【斐波那契数列】
- 【杭电oj】5620 - KK's Steel(递推)
- hdoj1254推箱子【dfs+bfs】
- java回调函数的一个生动解释
- android 读取本地超大图片
- Android学习笔记之ListView聊天界面
- HDU 5620 KK's Steel
- hdoj5620KK's Steel
- hihoCoder_W84 Lucky Substrings(基础做法)
- 【Android开发小记--10】一键锁屏功能实现
- 递归 (枚举)2
- 天佑中华,多难兴邦
- jQuery17(html,attr,removeAttr,动态创建元素)
- VS2013的MFC,获取程序的句柄
- python在Windows环境下如何快速安装 各类包
- c语言。利用交换概览把值从大到小输出