KK's Steel
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1112 Accepted Submission(s): 534
Problem Description
Our lovely KK has a difficult mathematical problem:he has a
N(1≤N≤10
18
)
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≤10
18
)
,indicating the length of the steel.
Each test case contains one line including a integer N(1≤N≤10
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
3Hint1+2+3=6 but 1+2=3 They are all different and cannot make a triangle.
Source
Recommend
hujie
斐波那契数列的性质。。这种特殊的题没意思积累一下好了
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
__int64 i,j,k,l,m,n,a[11000],p;
int main()
{
a[1]=1;
a[2]=2;
for(i=3;i<=10888;i++)
a[i]=a[i-1]+a[i-2];
scanf("%I64d",&p);
while(p--)
{
scanf("%I64d",&n);
k=0;
for(i=1;;i++)
{
k+=a[i];
if(k>n)
break;
}
printf("%I64d\n",i-1);
}
}