The mook jong
Accepts: 506
Submissions: 1281
Time Limit: 2000/1000 MS (Java/Others)
Memory Limit: 65536/65536 K (Java/Others)
Problem Description
ZJiaQ want to become a strong man, so he decided to play the mook jong。ZJiaQ want to put some mook jongs in his backyard. His backyard consist of n bricks that is 1*1,so it is 1*n。ZJiaQ want to put a mook jong in a brick. because of the hands of the mook jong, the distance of two mook jongs should be equal or more than 2 bricks. Now ZJiaQ want to know how many ways can ZJiaQ put mook jongs legally(at least one mook jong).
Input
There ar multiply cases. For each case, there is a single integer n( 1 < = n < = 60)
Output
Print the ways in a single line for each case.
Sample Input
1 2 3 4 5 6
Sample Output
1 2 3 5 8 12
1 #include <stdio.h> 2 #include <string.h> 3 int main() 4 { 5 long long n; 6 long long dp1[66],dp2[67]; 7 int i,j,k; 8 while(scanf("%I64d",&n)!=EOF) 9 { 10 memset(dp1,0,sizeof(dp1)); 11 memset(dp2,0,sizeof(dp2)); 12 dp1[1]=1,dp2[1]=1; 13 dp1[2]=2,dp2[2]=1; 14 dp1[3]=3,dp2[3]=1; 15 for(i=4;i<=n;i++) 16 { 17 dp1[i]=dp1[i-1]+dp2[i-1]; 18 dp2[i]=dp1[i-3]+dp2[i-3]; 19 } 20 printf("%I64d\n",dp1[n]+dp2[n]-1); 21 } 22 return 0; 23 }
时间: 2024-10-09 12:53:10