View Code of Problem 108

#include <iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	while(n--){
		string s;
		cin>>s;
		int len=s.length();
		if(len==1)
			cout<<1<<endl;
		else if(len==2)
			cout<<2<<endl;
		else{
			int a=1,b=2;
			for(int i=3;i<=len;i++){
				int t=b;
				b=a+b;
				a=t;
			}
			cout<<b<<endl;
		}
	}
	return 0;
}

Double click to view unformatted code.


Back to problem 108