View Code of Problem 3834

#include<bits/stdc++.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int sum=0;
		sum+=pow(2,n);
		for(int i=2;i<=n;i+=2){
			int q=1,p=1;
			for(int j=n;j>=i;j--){
				q*=j;
			}
			for(int j=1;j<=i;j++){
				p*=j;
			}
			sum+=q/p*pow(2,n-i);
		}
		cout<<sum<<endl;
	} 
	return 0;
}

Double click to view unformatted code.


Back to problem 3834