1. #include<iostream> 
  2. using namespace std; 
  3. int main() 
  4.     int a[5][2010]; 
  5.     int i,j; 
  6.     int temp; //储存进位数
  7.     int n,len,k; 
  8.     while(cin>>n) 
  9.     { 
  10.         memset(a,0,sizeof(a)); 
  11.         a[0][0]=a[1][0]=a[2][0]=a[3][0]=1; 
  12.         len=1; 
  13.         for(i=4;i<n;i++) 
  14.         { 
  15.             temp=0; 
  16.             for(j=0;j<len;j++) 
  17.             { 
  18. temp+=a[(i-4)%5][j]+a[(i-3)%5][j]+a[(i-2)%5][j]+a[(i-1)%5][j]; 
  19.                 a[i%5][j]=temp%10; 
  20.                 temp/=10; 
  21.             } 
  22.             while(temp) //注意
  23.             { 
  24.                 a[i%5][j++]=temp%10; 
  25.                 temp/=10; 
  26.             } 
  27.             len=j; 
  28.         } 
  29.         len--; 
  30.         for(;len>=0;len--) 
  31.         cout<<a[(n-1)%5][len]; 
  32.         cout<<endl; 
  33.     } 
  34.     return 0;