- #include<iostream>
- using namespace std;
- int main()
- {
- int a[5][2010];
- int i,j;
- int temp; //储存进位数
- int n,len,k;
- while(cin>>n)
- {
- memset(a,0,sizeof(a));
- a[0][0]=a[1][0]=a[2][0]=a[3][0]=1;
- len=1;
- for(i=4;i<n;i++)
- {
- temp=0;
- for(j=0;j<len;j++)
- {
- temp+=a[(i-4)%5][j]+a[(i-3)%5][j]+a[(i-2)%5][j]+a[(i-1)%5][j];
- a[i%5][j]=temp%10;
- temp/=10;
- }
- while(temp) //注意
- {
- a[i%5][j++]=temp%10;
- temp/=10;
- }
- len=j;
- }
- len--;
- for(;len>=0;len--)
- cout<<a[(n-1)%5][len];
- cout<<endl;
- }
- return 0;
- }
转载于:https://blog.51cto.com/4487906/1177256