您的位置:首页 > 其它

HDU-2046 骨牌铺方格【递推】

2015-11-12 15:09 351 查看
http://acm.hdu.edu.cn/showproblem.php?pid=2046

和前面的一样,a[i] = a[i-1] + a[i-2]

#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main()
{
int n;
while(cin>>n && n)
{
long long a[51];
a[1] = 1;
a[2] = 2;
a[3] = 3;
for(int i = 4;i<=n;i++)
{
a[i] = a[i-1] + a[i-2];
}
cout<<a
<<endl;
}

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: