HDU 2501 Tiling_easy version
2014-11-09 14:02
260 查看
http://acm.hdu.edu.cn/showproblem.php?pid=2501
递推公式:f[i]=f[i-1]+f[i-2]*2
思路:
1、对于i-1个来说剩两个直接补一个2*1的即可,有f[i-1]种
2、对于i-2个来说,剩四个,有三种方法:a、一个2*2;
b、两个横着的1*2;
c、两个竖着的1*2;
显然c中跟第一种冲突,所以有2*f[i-2]种方法由此推导出递推公式。
http://acm.hdu.edu.cn/showproblem.php?pid=2501
递推公式:f[i]=f[i-1]+f[i-2]*2
思路:
1、对于i-1个来说剩两个直接补一个2*1的即可,有f[i-1]种
2、对于i-2个来说,剩四个,有三种方法:a、一个2*2;
b、两个横着的1*2;
c、两个竖着的1*2;
显然c中跟第一种冲突,所以有2*f[i-2]种方法由此推导出递推公式。
#include <stdio.h> #include <string.h> #include <iostream> #include <algorithm> const int N=35; using namespace std; int f = {0,1,3}; int main(){ // freopen("in.txt", "r", stdin); for(int i=3; i<=30; i++) f[i] = f[i-1] + f[i-2]*2; int cas; scanf("%d",&cas); while(cas--){ int k; scanf("%d",&k); printf("%d\n",f[k]); } return 0; }
相关文章推荐
- hdu-2501-Tiling_easy version
- hdu 2501 Tiling_easy version
- HDU-2501 Tiling_easy version 递推
- HDU 2501 Tiling_easy version
- HDU 2501 Tiling_easy version
- HDU 2501--Tiling_easy version【递推】
- hdu 2501 Tiling_easy version 递推
- hdu 2501--Tiling_easy version
- hdu--2501--Tiling_easy version
- hdu 2501 Tiling_easy version
- hdu 2501 Tiling_easy version (水题)
- HDU 2501 Tiling_easy version(dp)
- 递推--HDU 2501Tiling_easy version
- HDU - 2501 - Tiling_easy version (简单递推关系!!)
- hdu-2501-Tiling_easy version
- HDU 2501 Tiling_easy version
- hdu 2501 Tiling_easy version
- HDU 2501 Tiling_easy version
- hDU 2501-Tiling_easy version
- HDU 杭电2501 Tiling_easy version【规律题】