Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main()
- {
- int n,a[40],b[40],c[40],d[40];
- cout<<"N ";cin>>n;
- a[1]=1;b[1]=1;c[1]=1;d[1]=1;
- for(int i=2;i<=n;i++)
- {
- a[i]=a[i-1]+c[i-1]+d[i-1];
- b[i]=b[i-1]+c[i-1]+d[i-1];
- c[i]=a[i-1]+b[i-1]+c[i-1]+d[i-1];
- d[i]=a[i-1]+b[i-1]+c[i-1]+d[i-1];
- }
- cout<<a[n]+b[n]+c[n]+d[n];
- return 0;
- }
Add Comment
Please, Sign In to add comment