HDU1568 Fibonacci Reasoning

Source: Internet
Author: User

Fibonacci

Time limit:1000/1000 MS (java/others) Memory limit:32768/32768 K (java/others)
Total submission (s): 4512 Accepted Submission (s): 2068


Problem Description2007 year has come. After 2006 years of cultivation, mathematical prodigy Zouyu finally put 0 to 100000000 of Fibonacci series
The values (f[0]=0,f[1]=1;f[i] = f[i-1]+f[i-2] (i>=2) are all backed down.
Next, Codestar decided to test him, so each asked him a number, he will say the answer, but some numbers are too long. So the provision of more than 4 people as long as the first 4 can be said, but Codestar himself cannot remember. So he decided to write a program to test whether Zouyu said it was correct.

Input inputs several digits n (0 <= n <= 100000000), one row per digit. Read the end of the file.

Output output F[N] The first 4 digits (if less than 4 digits, all outputs).

Sample Input012345353637383940

Sample Output011235922714932415390863241023

Authordaringqq

Sourcehappy 2007

Recommend8600 | We have carefully selected several similar problems for you:1060 1286 1788 1787 1047

Exercises
This question takes the formula of the sequence: an= (1/√5) * [((1+√5)/2) ^n-((1-√5)/2) ^n] (n=1,2,3 ...)

#include <stdio.h>#include<math.h>intMain () {intN,i; intf[ +]={0,1,1}; DoubleA= (1.0+SQRT (5.0))/2.0;  for(i=3; i<= -; i++)//Top 20 Items generatedF[i]=f[i-1]+f[i-2];  while(SCANF ("%d", &n)! =EOF) {        if(n<= -) printf ("%d\n", F[n]); Else        {            Doubleans=-0.5*LOG10 (5.0) +n*log10 (a); intanswer; Ans=ans-floor (ANS);//take a decimal partans=pow (Ten, ans);//take power onceAnswer=(int) (ans* +);//Type Conversionsprintf ("%d\n", answer); }    }    return 0;}

HDU1568 Fibonacci Reasoning

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.