标签:
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u
Description
Input
Output
Sample Input
Sample Output
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 5 using namespace std; 6 7 int a[2000],n,s; 8 9 /* 10 void dfs(int r) 11 { 12 if(r==n) {s++;return;} 13 if(r!=n-1) 14 { 15 for(int j=1;j<=3;j++) 16 if(j!=a[r-1]) 17 { 18 a[r]=j; 19 dfs(r+1); 20 } 21 } 22 else if(r==n-1) 23 { 24 for(int j=1;j<=3;j++) 25 if(j!=a[r-1]&&j!=a[0]) 26 { 27 a[r]=j; 28 dfs(r+1); 29 } 30 } 31 } 32 */ 33 34 int main() 35 { 36 long long b[55]; 37 b[1]=3,b[2]=6,b[3]=6; 38 for(int i=4;i<=50;i++) b[i]=b[i-1]+2*b[i-2]; 39 while(cin>>n) 40 { 41 cout<<b[n]<<endl; 42 } 43 }
标签:
原文地址:http://www.cnblogs.com/wsaaaaa/p/4294974.html