View Code of Problem 108

#include<iostream>
#include<cstdio>
#include<string>
#include<cmath>
#include<algorithm>

using namespace std;

int main()
{
    int n;
    cin>>n;
    while(n--)
    {
        string str;
        cin>>str;
        int t=str.size();
        int a[t+1];
        a[1]=1;
        a[2]=2;
        for(int i=3;i<=t;i++)
            a[i]=a[i-1]+a[i-2];
        cout<<a[t]<<endl;
    }
}

Double click to view unformatted code.


Back to problem 108