Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- static long long int count =0;
- void compute(int arr[],int i,int n)
- {
- if(i==n-1)
- {
- count++;
- return;
- }
- if(arr[i]==0)
- {
- arr[i+1]=0;
- compute(arr,i+1,n);
- arr[i+1]=1;
- compute(arr,i+1,n);
- }
- if(arr[i]==1)
- {
- arr[i+1]=0;
- compute(arr,i+1,n);
- }
- }
- int main()
- {
- int t;
- cin>>t;
- while(t--)
- {
- count=0;
- //cout<<"Count "<<count<<endl;
- int n;
- cin>>n;
- int arr[n]={0};
- compute(arr,0,n);
- arr[0]=1;
- compute(arr,0,n);
- cout<<count<<endl;
- }
- return 0;
- }
Add Comment
Please, Sign In to add comment