Monday, July 18, 2016

Published July 18, 2016 by with 0 comment

UVA 11000 Solution

#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;
}
      edit

0 comments:

Post a Comment