Monday, July 18, 2016

UVA 11000 Solution

Unknown
#include<cstdio>
using namespace std;
typedef long long int lld;

lld t[100]={0};

lld total(int n)
{
    if (n<0) return 0;
    if (t[n]==0)
    t[n]=total(n-2)+total(n-1)+1;
    return t[n];
}
int main()
{
    int n;
    t[0]=1;
    t[1]=2;
    while (scanf("%d",&n)==1)
    {
        if (n==-1) return 0;
        printf("%lld %lld\n",total(n-1),total(n));
    }
    return 0;
}

Unknown

Studying at Shahjalal University of Science and Technology, Sylhet.

0 comments:

Post a Comment

Coprights @ 2016,