Wednesday, July 20, 2016

uva 12459 solution

Unknown
#include<cstdio>
using namespace std;
typedef unsigned long long llu;

llu f[90]={0};
llu fib(int n)
{
    if (n<4) f[n]=n;
    if (f[n]==0) f[n]=fib(n-2)+fib(n-1);
    return f[n];
}

int main()
{
    int n;
    while (scanf("%d",&n)&& n)
    printf("%llu\n",fib(n));
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,