View Code of Problem 3695

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

Double click to view unformatted code.


Back to problem 3695