剑指offer-12-矩阵覆盖
来源:互联网 发布:汉诺塔问题c语言代码 编辑:程序博客网 时间:2024/06/08 04:28
题目描述:可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法?
分析:
1、当 n=1时候,result = 1;
2、当 n =2时候,result = 2
3、当n=3时候,result = 3
继续往下推会得到f(n) = f(n-1) +f(n-2)(n>2).
代码同上一篇博客的代码一样了:
public int RectCover(int target) {
if(target<1){
return 0;
}else if(target == 1 || target == 2){
return target;
}else{
return RectCover(target-1)+RectCover(target-2);
}
}
阅读全文
0 0
- 剑指offer-12-矩阵覆盖
- 【剑指Offer】:矩阵覆盖
- 剑指offer——矩阵覆盖
- 【剑指offer】题9:矩阵覆盖
- [牛客网,剑指offer,python] 矩阵覆盖
- 剑指offer(C++)——矩阵覆盖
- 剑指offer--(12) 矩形覆盖
- 剑指offer--矩形覆盖
- 剑指offer--矩形覆盖
- 《剑指offer》矩形覆盖
- 剑指offer 矩形覆盖
- 《剑指offer》矩形覆盖
- 剑指 offer:矩形覆盖
- 【剑指Offer】矩形覆盖
- 剑指offer 矩形覆盖
- 剑指offer-矩形覆盖
- 剑指Offer 矩形覆盖
- 剑指offer 矩形覆盖
- Makecert傻瓜教程——简单使用说明
- Linux 查看日志命令
- Node.js的express框架
- Maven 之 deploy 发布到私服上
- Shell命令之编译/安装/运行/卸载iOS APP
- 剑指offer-12-矩阵覆盖
- linux下安装mysql5.7.17及简单配置&&HIVE安装和使用
- 局域网中window可以解析hostname,而linux却不可以?
- 每天给自己提几个C++技术问题
- oracle一次插入多条数据
- 【C语言】模拟实现strncpy strncat strncmp strchr strrchr函数
- python字符串,列表
- 使用 Git & Repo 下载代码
- 牛客网_华为机试_006_质数因子