HH Internship (hpu1287) (Fibonacci application)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.