例如n=3时,为2× 3方格,骨牌的铺放方案有三种,如下图:
2
Author
lcy
Source
递推求解专题练习(For Beginner)附上AC代码:
#include <iostream> #include <cstdio> #include <string> #include <cmath> #include <iomanip> #include <ctime> #include <climits> #include <cstdlib> #include <cstring> #include <algorithm> using namespace std; typedef unsigned int UI; typedef long long LL; typedef unsigned long long ULL; typedef long double LD; const double PI = 3.14159265; const double E = 2.71828182846; int main() { ios::sync_with_stdio(false); LL num[51] = {1, 1, 2}; for (int i=3; i<51; i++) num[i] = num[i-1]+num[i-2]; int n; while (cin >> n) { cout << num[n] << endl; } return 0; }
版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/silenceneo/article/details/47679695