题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=5620
题意:给你一个n长的钢管,要分的尽可能多,且任意三条不能构成三角形
题解:看hint就知道用递推来解
1 #include<cstdio> 2 #define F(i,a,b) for(int i=a;i<=b;++i) 3 4 long long a[100],b[100],n;int t,l,r,mid; 5 6 int main(){ 7 b[1]=1,b[2]=2,a[1]=b[1]; 8 F(i,3,90)b[i]=b[i-1]+b[i-2]; 9 F(i,2,90)a[i]+=a[i-1]+b[i]; 10 scanf("%d",&t); 11 while(t--){ 12 scanf("%lld",&n); 13 for(l=1,r=87;l<=r;)if(a[mid=l+((r-l)>>1)]>n)r=mid-1;else l=mid+1; 14 printf("%d\n",l-1); 15 } 16 return 0; 17 }