HH Internship Time limit: 1 Sec Memory Limit: MB
Submit: Solved: 29
[Submit] [Status] [Web Board] Description
This semester has been 15 weeks, HH suddenly to the training center internship, think to hold pliers, saw what, head is a bit big, because it is very fun, but, is also very tired, watching the study of the younger brother sitting in the computer room leisurely knocking code, HH seniors decided to let them busy busy, this problem is for you out of, learn younger brothers, Come on! The problem is very simple, just need to hands on enough, the request is, give you n meters long steel, rebar everybody know? It's a steel bar, you know that? Do not know to go home to ask Ma Ma, the purpose is very simple, let you do it yourself to cut this long piece of steel into the M section, to ensure that any three of them can not form a triangle, it sounds like chaos, in fact, I want the answer is very simple, is that you can cut this bar into how many, the number of the most, there is no less than 1 meters in length. Easy, let's take time to AC.
Input
The first line enters a T, and the next T line, each row has a number N (4<=n<=1000000);
Output
Output takes up one row, corresponding to the maximum number of bars per n output m
Sample Input
27
Sample Output
410
HINT
Source
The fifth annual ACM Program Design Competition of Henan Polytechnic University
#include <stdio.h> int a[30],b[10000000]; int main () { int i,n,test,sum=2; A[0]=1,a[1]=1; for (i=2;i<30;i++) { a[i]=a[i-1]+a[i-2]; Sum+=a[i]; b[sum]=i+1; } scanf ("%d", &test); while (test--) { scanf ("%d", &n); while (b[n]==0) { n--; } printf ("%d\n", B[n]); } return 0; }
HH Internship (hpu1287) (Fibonacci application)