标签:
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 are 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.
#include<stdio.h> #include<iostream> #include<algorithm> using namespace std; typedef long long LL; LL a[70]; LL ans[70]; int main(void) { int n; a[1]=1;a[2]=1;a[3]=1; ans[1]=1;ans[2]=2;ans[3]=3; LL sum=0; for (int i=4;i<=60;++i) { sum+=a[i-3]; a[i]=sum+1; ans[i]=ans[i-1]+a[i]; } while (scanf("%d",&n)!=EOF) { cout<<ans[n]<<endl; } }
标签:
原文地址:http://www.cnblogs.com/123-123/p/5189413.html